[英]Using Encoded Polyline in a Google Maps Static Map Call
Ok, maybe this is a stupid question but i spend hours and didn't find something to help me to discover this. 好的,也许这是一个愚蠢的问题,但是我花了几个小时却没有找到任何东西可以帮助我发现这个问题。 I'm using Google Maps Static Map to draw a map with many points in path, i'm doing one request like this one:
我正在使用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
Works fine! 工作正常! Now i'm trying to use Polylines to create a short request because google api limit is 2000 characters and for my app i have situations with more than 100 coordinates points to put in path.
现在,我正在尝试使用Polylines创建一个简短的请求,因为Google api的限制是2000个字符,对于我的应用,我遇到的情况是要放置100个以上的坐标点。 I have the algorithm(PHP) to encode the coordinates in Polylines,after this i request again with the coordinates encoded.
我有算法(PHP)在折线中编码坐标,此后我再次要求使用编码后的坐标。 The result for same request but with Polyline:
相同请求但使用折线的结果:
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
Don't work...so my question here is: Can i use the encoded Polyline in that kind of call in Google API like i'm doing now without Polyline or i'm doing something wrong ? 不起作用...所以我在这里的问题是:我可以像在不使用Polyline的情况下那样立即在Google API的调用中使用编码的Polyline还是做错了什么?
You are missing enc:
: static map with encoded string 您缺少
enc:
具有编码字符串的静态映射
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
From the documentation : 从文档中 :
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.
您可以使用路径的位置声明中的enc:前缀,而不是一系列位置,而是将路径声明为编码的折线。 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.
请注意,如果您为地图提供了编码的折线路径,则无需指定(通常需要)center和zoom参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.