gpt4 book ai didi

json - 有人知道如何将 GMap 静态 JSON 转换为 HTML url?

转载 作者:行者123 更新时间:2023-12-05 00:25:56 28 4
gpt4 key购买 nike

我已经从 snazzymaps.com 下载了一个示例样式的 map .我尝试转换为类似 http://maps.googleapis.com/maps/api/staticmap?sensor=false&size=512x512&zoom=15&center=Chicago 的网址但我做得不好。我正在尝试转换下一个示例:

Example Google Map Styled Static

JSON 看起来像这样:

styles: [

{"featureType":"poi","stylers":[{"visibility":"off"}]},{"stylers":[{"saturation":-70},{"lightness":37},{"gamma":1.15}]},{"elementType":"labels","stylers":[{"gamma":0.26},{"visibility":"off"}]},

{"featureType":"road","stylers":[{"lightness":0},{"saturation":0},{"hue":"#ffffff"},{"gamma":0}]},

{"featureType":"road","elementType":"labels.text.stroke","stylers":[{"visibility":"off"}]},

{"featureType":"road.arterial","elementType":"geometry","stylers":[{"lightness":20}]},

{"featureType":"road.highway","elementType":"geometry","stylers":[{"lightness":50},{"saturation":0},{"hue":"#ffffff"}]},

{"featureType":"administrative.province","stylers":[{"visibility":"on"},{"lightness":-50}]},

{"featureType":"administrative.province","elementType":"labels.text.stroke","stylers":[{"visibility":"off"}]},

{"featureType":"administrative.province","elementType":"labels.text","stylers":[{"lightness":20}]}

我已经转换了下一个,但它不起作用,我做错了什么!! :S
http://maps.googleapis.com/maps/api/staticmap?sensor=false&size=512x512&zoom=15&center=Chicago&format=png&style=feature:poi%7Cvisibility:off%7Csaturation:-70%7Clightness:37%7Cgamma:1.15%7Celement:labels%7Cgamma:0.26%7Cvisibility:off&style=road%7Clightness:0%7Csaturation:0%7Chue:#ffffff%7Cgamma:0&style=road%7Celement:labels.text.stroke%7Cvisibility:off&style=road.arterial%7Celement:geometry%7Clightness:20&style=road.highway%7Celement:geometry%7Clightness:50%7Csaturation:0%7Chue:#ffffff&style=administrative.province%7Cvisibility:on%7Clightness:-50&style=administrative.province%7Celement:labels.text.stroke%7Cvisibility:off&style=administrative.province%7Celement:labels.text%7Clightness:20

如果有人能给我一个建议,我将不胜感激。

最佳答案

您应该阅读 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.



所以你需要传递多个 &style=到网址。 (您设计的每个功能/元素对应一个)
(你已经这样做了)

对于您需要使用的颜色 0xRRGGBB句法。
同样在您的示例中,JSON 中的第一行包含三个组。第二个指的是 map 的全局样式,第三个指的是 map 中的所有标签,而不是 feature:poi .所以你需要另一种风格来定位 feature:all一个用于 element:labels
您链接到的 snazzymap 示例将转换为类似的内容(并非所有样式都包括在内)
  • &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

  • (请记住,将 visibility 设置为 off 时,操作该特征/元素的任何其他属性都没有意义)

    当添加到 url 时,你会得到

    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

    这是将 snazzymap json 转换为 Google 静态 map url 的小工具。

    工具在 http://jsfiddle.net/gaby/s6Dyp/

    关于json - 有人知道如何将 GMap 静态 JSON 转换为 HTML url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23153166/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com