Rendering polygon with Google Static Maps API URL

与世无争的帅哥 提交于 2019-12-21 05:01:01

问题


I created a script to store dynamic map inputs by appending attributes to a Static Maps URL (so we can refer back to it after a user submits).

For reasons I can't yet determine, the Polygon is not rendering at all with the basic static maps URL, but it works with a 3rd party site's static maps function. According to Static Maps API examples there should be no issue, but I can't seem to recreate the Polygon.

Working version (with same attributes in URL, though it ignores Satellite and zoom resolution) from 3rd Party site.

Desired version missing the polygon.

The question is: Am I missing some parameter? I do have an API key which I removed from the URL, so that must not be the issue..


回答1:


Your original Desired Version uses a parameter that Google does not support. Removing just opacity:0| and it works:

http://maps.googleapis.com/maps/api/staticmap?center=33.402285,-111.94271500000002&zoom=20&size=600x600&maptype=satellite&sensor=false&path=color%3ared|weight:1|fill%3awhite|33.4022475,-111.9426775|33.4022475,-111.9427525|33.4023225,-111.9427525|33.4023225,-111.9426775|33.4022475,-111.9426775

Opacity on google maps is set in the color as a 32-bit hexadecimal value, so

  • Thin blue line, 0% opacity: path=color:0x0000ff00
  • Solid red line with 100% opacity: path=color:0xff0000ff
  • The default is 50% if you pass a 24-bit color: 0x0000ff (50% opacity, blue)

So I think this is what you are looking for (or really close):

http://maps.googleapis.com/maps/api/staticmap?center=33.402285,-111.942715&zoom=20&size=600x600&maptype=satellite&sensor=false&path=color:red|weight:1|fillcolor:white|33.4022475,-111.9426775|33.4022475,-111.9427525|33.4023225,-111.9427525|33.4023225,-111.9426775|33.4022475,-111.9426775



来源:https://stackoverflow.com/questions/13147503/rendering-polygon-with-google-static-maps-api-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!