在 Google 地图静态地图调用中使用编码折线
Using Encoded Polyline in a Google Maps Static Map Call
好吧,也许这是一个愚蠢的问题,但我花了好几个小时却没有找到可以帮助我发现这个问题的东西。
我正在使用 Google Maps Static Map 来绘制路径中有很多点的地图,我正在做一个这样的请求:
https://maps.googleapis.com/maps/api/staticmap?size=1000x500&maptype=roadmap&markers=icon:http://api.appcargo.com/app_images/ic_pin.png|44.80006858,20.4791788&markers=icon:http://api.appcargo.com/app_images/ic_pin_destination_toolbar.png|44.8013566,20.4804733&path=color:0xff0000ff|weight:5|44.80006858,20.4791788|44.80028333,20.47892833|44.80152833,20.48004833|44.80135667,20.48047333&format=jpg
结果:
工作正常!现在我正在尝试使用 Polylines 创建一个简短的请求,因为 google api 限制是 2000 个字符,对于我的应用程序,我有超过 100 个坐标点要放在路径中的情况。
我有算法(PHP)来编码折线中的坐标,在此之后我再次请求编码的坐标。
相同请求但使用折线的结果:
https://maps.googleapis.com/maps/api/staticmap?size=1000x500&maptype=roadmap&markers=icon:http://api.appcargo.com/app_images/ic_pin.png|44.80006858,20.4791788&markers=icon:http://api.appcargo.com/app_images/ic_pin_destination_toolbar.png|44.8013566,20.4804733&path=color:0xff0000ff|weight:5|m_mpG{y~{Bi@p@yF_F`@sA&format=jpg
结果:
不起作用...所以我的问题是:我可以在 Google API 的那种调用中使用编码的折线,就像我现在在没有折线的情况下所做的那样,或者我我做错了什么?
您缺少enc:
:static map with encoded string
https://maps.googleapis.com/maps/api/staticmap?size=1000x500&maptype=roadmap&markers=icon:http://api.appcargo.com/app_images/ic_pin.png%7C44.80006858,20.4791788&markers=icon:http://api.appcargo.com/app_images/ic_pin_destination_toolbar.png%7C44.8013566,20.4804733&path=color:0xff0000ff%7Cweight:5%7Cenc:m_mpG%7By~%7BBi@p@yF_F%60@sA&format=jpg
Encoded Polylines
Instead of a series of locations, you may instead declare a path as an encoded polyline by using the enc: prefix within the location declaration of the path. Note that if you supply an encoded polyline path for a map, you do not need to specify the (normally required) center and zoom parameters.
好吧,也许这是一个愚蠢的问题,但我花了好几个小时却没有找到可以帮助我发现这个问题的东西。 我正在使用 Google Maps Static Map 来绘制路径中有很多点的地图,我正在做一个这样的请求:
https://maps.googleapis.com/maps/api/staticmap?size=1000x500&maptype=roadmap&markers=icon:http://api.appcargo.com/app_images/ic_pin.png|44.80006858,20.4791788&markers=icon:http://api.appcargo.com/app_images/ic_pin_destination_toolbar.png|44.8013566,20.4804733&path=color:0xff0000ff|weight:5|44.80006858,20.4791788|44.80028333,20.47892833|44.80152833,20.48004833|44.80135667,20.48047333&format=jpg
结果:
工作正常!现在我正在尝试使用 Polylines 创建一个简短的请求,因为 google api 限制是 2000 个字符,对于我的应用程序,我有超过 100 个坐标点要放在路径中的情况。 我有算法(PHP)来编码折线中的坐标,在此之后我再次请求编码的坐标。 相同请求但使用折线的结果:
https://maps.googleapis.com/maps/api/staticmap?size=1000x500&maptype=roadmap&markers=icon:http://api.appcargo.com/app_images/ic_pin.png|44.80006858,20.4791788&markers=icon:http://api.appcargo.com/app_images/ic_pin_destination_toolbar.png|44.8013566,20.4804733&path=color:0xff0000ff|weight:5|m_mpG{y~{Bi@p@yF_F`@sA&format=jpg
结果:
不起作用...所以我的问题是:我可以在 Google API 的那种调用中使用编码的折线,就像我现在在没有折线的情况下所做的那样,或者我我做错了什么?
您缺少enc:
:static map with encoded string
https://maps.googleapis.com/maps/api/staticmap?size=1000x500&maptype=roadmap&markers=icon:http://api.appcargo.com/app_images/ic_pin.png%7C44.80006858,20.4791788&markers=icon:http://api.appcargo.com/app_images/ic_pin_destination_toolbar.png%7C44.8013566,20.4804733&path=color:0xff0000ff%7Cweight:5%7Cenc:m_mpG%7By~%7BBi@p@yF_F%60@sA&format=jpg
Encoded Polylines
Instead of a series of locations, you may instead declare a path as an encoded polyline by using the enc: prefix within the location declaration of the path. Note that if you supply an encoded polyline path for a map, you do not need to specify the (normally required) center and zoom parameters.