(address, radius, callback)
| 31 | }); |
| 32 | }, |
| 33 | async searchGeo (address, radius, callback) { |
| 34 | /** 地理转坐标并获取radius范围内的路网数据并转换为geoData |
| 35 | * @name: |
| 36 | * @param {address 中文地址 radius 范围 traff 路网数据} |
| 37 | * @return {*} |
| 38 | */ |
| 39 | const traff = { |
| 40 | type: "FeatureCollection", |
| 41 | name: "dl2", |
| 42 | crs: { |
| 43 | type: "name", |
| 44 | properties: { |
| 45 | name: "urn:ogc:def:crs:OGC:1.3:CRS84" |
| 46 | } |
| 47 | }, |
| 48 | features: [] |
| 49 | } |
| 50 | let center = [] |
| 51 | if (typeof address === 'object') { |
| 52 | center = address |
| 53 | } else { |
| 54 | const { data } = await axios.get(`https://restapi.amap.com/v3/geocode/geo?key=502123a4f08bd95be55b49ae6eabd728&address=${address}`) |
| 55 | center = data.geocodes[0].location.split(',') |
| 56 | } |
| 57 | // 获取转换后的线条数据 |
| 58 | const traffData = await axios.get(`https://restapi.amap.com/v3/traffic/status/circle?location=${center.join()}&radius=${radius}&key=502123a4f08bd95be55b49ae6eabd728&extensions=all`) |
| 59 | traffData.data.trafficinfo.roads.map(item => { |
| 60 | const coordinates = [] |
| 61 | const coord = [] |
| 62 | coordinates.push(item.polyline.split(';')) |
| 63 | coordinates.map(item => { |
| 64 | coord.push(item.map(ite => { |
| 65 | return ite.split(',').map(it => { |
| 66 | return it = Number(it) |
| 67 | }) |
| 68 | })) |
| 69 | }) |
| 70 | coord.map(item => { |
| 71 | traff.features.push({ type: 'Feature', properties: {}, geometry: { type: 'MultiLineString', coordinates: [item] } }) |
| 72 | }) |
| 73 | }) |
| 74 | callback({ traff, center }) |
| 75 | }, |
| 76 | drawTraffLineLayer (scene, traff, config) { |
| 77 | /** 绘制路网轨迹图 |
| 78 | * @name: |
nothing calls this directly
no outgoing calls
no test coverage detected