本文介绍了如何从Google Maps Directions Api获取多段线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试绘制一个的问题使用谷歌地图方向Api,但我该如何使用JSON值来做到这一点,因为在api中,有很多纬度和长度以及多边形。像这样的点:
和I don我不知道应该使用哪一个,任何人都可以帮助我:)
{
geocoded_waypoints:[
$},
{}
],
routes:[
{
界限:{
东北:{
lat:39.2846595,
lng:-8.7036795
},
西南:{
lat:38.7223249,
lng:-9.1393372
}
},
版权:Dados do mapa©2017 Google,Inst。Geogr。Nacional,
双腿:[
{
dist ance:{},
持续时间:{},
end_address:Lisboa,Portugal,
end_location:{
lat:38.7223249,
lng:-9.1393372
},
start_address:葡萄牙圣塔伦,
start_location:{
lat:39.2846595,
lng:-8.7049071
},
步骤:[
{
distance:{},
duration:{},
end_location:{
lat:39.2822117,
lng:-8.7036403
},
html_instructions:Siga< b> sul< / b> em
$ b points:cxwnFtdct @ JEVGLCR?PDTFNHTNNNPJPDRDN?JCHCv @ i @ VQTK`CkF
},
start_location:{
lat:39.2846595,
lng:-8.7049071
},
travel_mode:DRIVING
},
{},
],
traffic_speed_entry:[],
via_waypoint:[]
}
],
overview_polyline:{points:cxwnFtdct @ dAQlAf @ fAf @ |水溶液@升@] pCcFhCjA | LfJlAT〜@ IPDI @戳@频率@ HXI @ T @ kBhBeBx @ QZ @ Z @ dClHzFpW`H | RvTpj @`AxAdBdAnAXhB FBK @ rAcAnG_HhCgAjAKrATbA`Al @ lBHnAc @ rFgBhIkCxMBfIlBvHnBtCnB |?AnEdCrJxFj @ fB的3 H @ OhAgCtHGfCl @ jAlA\jE] tDBzBb @ tLxFtK〜E`d @ hShIzEtDhDxDrEfDpFlFjNvDtRdDjThF`TzH`QhEhG | EvFhL`JpJtE | LpEdOpFjOzGlPfJlHzE〜NjLfQvPfP | RtHrKxDjGfI | NdHbOvGjPfCbHpCtIvJh_ @ VG | [| CtNvFvSvE〜MFI | QzLbTfNxQbKlKrRzP | NnNvNlQjIzMnLfV`T | H @ nDbHhIdMxFjH〜JrMnEfHzIrQfHvOtEjI | MnQfNzP`FzI〜戊nLrKp [nDlHvErHzL〜MbRbM`EjCjFxEtRnX | d〜EjIhI〜WrRxGlGdFnG`JjNxHzKfTxVfKfRfMbRlErHtBlFxIjYvHnPpBtFxF〜WpCjHjGhJfDzClF〜CnDlArDl @ pC\vHXvX [lOaB | GcBdFqBxQwJbDmAxE_ApJ_ @ jEXtItBrQ〜EbQbDlUfBpMfA | IxCbF`DhGlGnJjKtJrF`SpFbRnDdUxAbGrAlEjBnFpDtNnMfGlE〜[lTbRdQjTpUxH`GjHfEnGlC`O | DrUxEnEzAfFrBnSpIjPnDxSlAf\lAl 〜@ ^ hDzRrAjOpBvKrBrQtEv @ pM`` RPRR | JxSdMlGnGfGtH〜HxFdFlBtGfApGp @的bG | AnHxD | FzFrH`L〜FVH | HrFrFtBtFjA〜// @山PHR | FhA`IfDpEbDzFxGrHrKhEtErF`EnS`MzMvItSdUfF〜DTE〜C | SrInEnBzDtCxN`QpQfVtQ〜YJN @〜FANK `RvLlRzEjF | GlFrc @ vUfRjKfIvGxDhEjIxKdN〜T`L〜MrFvE〜LhIlp @ FB @ xCtBzFtFbEzFbDrGhH`TfF | JnGfHzEdD | UdIpTdHtKtFj] nUrEzC〜[pTfLfG | EBB〜KfCnTvDpmAxSzs @〜LhOfDzOdFfOxGdY`O`k @ zYnVzMlK | HrFjFbXj [rCbCvDfB | FfBbD ^ xRBlb @nBrIdArJvDfD | B | FzFvFzHnCbIDrCk @ dA_A_ @ q因子@兆赫@ sAvAJ ^ F 5 R @ N @ X @ UR_ @ fBGjET`S〜@ RO @ pCpXpAfFp @ dEhCnGtE @ HXL @ N @ H ^ W | ASpShAbZxAtPp @〜SjAzGZKdDStBd @ X @ dC @ nEVz @ HtAp @ b @ \OZ | AbBxDnFJf @
},
摘要:A1,
警告:[],
waypoint_order:[]
}
],
status:OK
}
$ c
解决方案将overview_polyline转换为LatLng列表并添加为映射中的polyling
使用由Google提供的PolyUtil。
I'm trying to draw a polyline using the Google Maps Directions Api, but how do I use the JSON values to make this, because in the api, there is a lot of lat and long and polylines.points like this:
and I don't know which one should I use, can anyone help me :)
{ geocoded_waypoints: [ {}, {} ], routes: [ { bounds: { northeast: { lat: 39.2846595, lng: -8.7036795 }, southwest: { lat: 38.7223249, lng: -9.1393372 } }, copyrights: "Dados do mapa ©2017 Google, Inst. Geogr. Nacional", legs: [ { distance: {}, duration: {}, end_address: "Lisboa, Portugal", end_location: { lat: 38.7223249, lng: -9.1393372 }, start_address: "Santarém, Portugal", start_location: { lat: 39.2846595, lng: -8.7049071 }, steps: [ { distance: {}, duration: {}, end_location: { lat: 39.2822117, lng: -8.7036403 }, html_instructions: "Siga <b>sul</b> em direção a <b>N3</b>", polyline: { points: "cxwnFtdct@JEVGLCR?PDTFNHTNNNPJPDRDN?JCHCv@i@VQTK`CkF" }, start_location: { lat: 39.2846595, lng: -8.7049071 }, travel_mode: "DRIVING" }, {}, ], traffic_speed_entry: [], via_waypoint: [] } ], overview_polyline: { points:"cxwnFtdct@dAQlAf@fAf@|Aq@l@]pCcFhCjA|LfJlAT~@IpDi@jAb@f@HXi@t@kBhBeBx@Qz@z@dClHzFpW`H|RvTpj@`AxAdBdAnAXhB?fBk@rAcAnG_HhCgAjAKrATbA`Al@lBHnAc@rFgBhIkCxMBfIlBvHnBtCnB|AnEdCrJxFj@fB@h@OhAgCtHGfCl@jAlA\jE]tDBzBb@tLxFtK~E`d@hShIzEtDhDxDrEfDpFlFjNvDtRdDjThF`TzH`QhEhG|EvFhL`JpJtE|LpEdOpFjOzGlPfJlHzE~NjLfQvPfP|RtHrKxDjGfI|NdHbOvGjPfCbHpCtIvJh_@vG|[|CtNvFvSvE~MfI|QzLbTfNxQbKlKrRzP|NnNvNlQjIzMnLfV`T|h@nDbHhIdMxFjH~JrMnEfHzIrQfHvOtEjI|MnQfNzP`FzI~EnLrKp[nDlHvErHzL~MbRbM`EjCjFxEtRnX|D~EjIhI~WrRxGlGdFnG`JjNxHzKfTxVfKfRfMbRlErHtBlFxIjYvHnPpBtFxF~WpCjHjGhJfDzClF~CnDlArDl@pC\vHXvX[lOaB|GcBdFqBxQwJbDmAxE_ApJ_@jEXtItBrQ~EbQbDlUfBpMfA|IxCbF`DhGlGnJjKtJrF`SpFbRnDdUxAbGrAlEjBnFpDtNnMfGlE~[lTbRdQjTpUxH`GjHfEnGlC`O|DrUxEnEzAfFrBnSpIjPnDxSlAf\lAl~@hDzRrAjOpBvKrBrQtEv^pM``@rPrR|JxSdMlGnGfGtH~HxFdFlBtGfApGp@bG|AnHxD|FzFrH`L~FvH|HrFrFtBtFjA~Mt@pHR|FhA`IfDpEbDzFxGrHrKhEtErF`EnS`MzMvItSdUfF~DtE~B|SrInEnBzDtCxN`QpQfVtQ~Yjn@~fAnK`RvLlRzEjF|GlFrc@vUfRjKfIvGxDhEjIxKdN~T`L~MrFvE~LhIlp@fb@xCtBzFtFbEzFbDrGhH`TfF|JnGfHzEdD|UdIpTdHtKtFj]nUrEzC~[pTfLfG|EbB~KfCnTvDpmAxSzs@~LhOfDzOdFfOxGdY`O`k@zYnVzMlK|HrFjFbXj[rCbCvDfB|FfBbD^xRBlb@nBrIdArJvDfD|B|FzFvFzHnCbIDrCk@dA_A_@q@mHz@sAvAJ^f@r@n@x@UR_@fBGjET`S~@ro@pCpXpAfFp@dEhCnGtE@HXl@n@H^W|ASpShAbZxAtPp@~SjAzGZKdDStBd@x@dC@nEVz@HtAp@b@\OZ|AbBxDnFJf@" }, summary: "A1", warnings: [], waypoint_order: [] } ], status: "OK" }解决方案Convert overview_polyline into list of LatLng and add as polyling in map
Use PolyUtil provided from google.
这篇关于如何从Google Maps Directions Api获取多段线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!