Someone knows how to convert GMap Static JSON to a HTML url?

怎甘沉沦 提交于 2019-12-04 13:46:32

You should read the styled maps section of the Static Maps API Guide.

A customized "styled" map consists of one or more specified styles, each indicated through a style parameter within the Static Map request URL. Additional styles are specified by passing additional style parameters.

So you need to pass multiple &style= to the URL. (one for each feature/element you style)
(You already do that)

For the colors you need to use the 0xRRGGBB syntax.
Also in your example the first line in your JSON holds threee groups. The second refers to the global styling of the map and the third to all the labels in the map, not to the feature:poi. So you need another style for that which targets feature:all and one for element:labels

The snazzymap example you linked to would translate to something like (not all styles are included)

  • &style=feature:poi|visibility:off
  • &style=feature:all|saturation:-70|lightness:37|gamma:1.15
  • &style=element:labels|visibility:off
  • &style=feature:road|lightness:0|saturation:0|hue:0xffffff|gamma:0
  • &style=feature:road.highway|element:geometry|lightness:50|saturation:0|hue:0xffffff

(keep in mind that when setting visibility to off there is no point in manipulating any other property of that feature/element)

And when added to the url, you would get

http://maps.googleapis.com/maps/api/staticmap?sensor=false&size=815x815&zoom=15&center=cicago&style=feature:poi|visibility:off&style=feature:all|saturation:-70|lightness:37|gamma:1.15&style=element:labels|visibility:off&style=feature:road|lightness:0|saturation:0|hue:0xffffff|gamma:0&style=feature:road.highway|element:geometry|lightness:50|saturation:0|hue:0xffffff


And here is little tool to convert snazzymap json to Google Static Map urls..

Tool at http://jsfiddle.net/gaby/s6Dyp/

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