使用Google静态地图API网址呈现多边形 [英] Rendering polygon with Google Static Maps API URL

查看:120
本文介绍了使用Google静态地图API网址呈现多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个脚本来存储动态地图输入,方法是将属性附加到静态地图URL(所以我们可以在用户提交后引用它)。

由于我还不能确定的原因,Polygon并没有使用基本的静态地图URL进行渲染,但它可以与第三方网站的静态地图功能一起使用。根据静态地图API示例应该没有问题,但我似乎无法重新创建多边形。



工作版本(在URL中具有相同的属性,尽管它忽略了Satellite和zoom分辨率)来自第三方网站。

所需版本缺少多边形。



问题是:我是否缺少一些参数?我确实有一个我从网址中删除的API密钥,所以一定不能是这个问题。

原文 em>期望的版本使用Google不支持的参数。删除 opacity:0 | 并且它可以正常工作:



http://maps.googleapis.com/maps/api/staticmap?center=33.402285,-111.94271500000002&zoom=20& ;大小= 600×600&安培;地图类型=卫星&安培;传感器=假安培;路径=彩色%3ared |重量:1 |填充%3awhite | 33.4022475,-111.9426775 | 33.4022475,-111.9427525 | 33.4023225,-111.9427525 | 33.4023225,-111.9426775 | 33.4022475, - 111.9426775



Google地图上的不透明度设置在颜色作为32位十六进制值,因此


  • 薄蓝线,0%不透明度:path = color :0x0000ff00

  • 纯红色的lin e:100%不透明度:路径=颜色:0xff0000ff

  • 如果您传递24位颜色,则默认为50%:0x0000ff(50%不透明度,蓝色) $ b


所以我认为这就是你要找的(或者真的很接近):

http://maps.googleapis.com/maps/api/staticmap?center = 33.402285,-111.942715和缩放= 20&安培;大小= 600×600&安培;地图类型=卫星&安培;传感器=假安培;路径=颜色:红|重量:1 |填充颜色:白色| 33.4022475,-111.9426775 | 33.4022475,-111.9427525 | 33.4023225, - 111.9427525 | 33.4023225,-111.9426775 | 33.4022475,-111.9426775


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..

解决方案

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

这篇关于使用Google静态地图API网址呈现多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆