在Google Maps API上为“感兴趣的区域”添加颜色?

时间:2016-07-26 21:01:21

标签: javascript google-maps google-maps-api-3

谷歌刚刚更改了地图颜色方案,它搞砸了我正在处理的网站上的自定义颜色。这是他们博客上的新闻:

Discover the action around you with the updated Google Maps

现在,那里的技术信息不多。有没有人已经找到了哪里可以改变“感兴趣的区域”的浅棕色/橙色??

从测试here开始(此链接位于他们的开发网站上),唯一能做任何事情的是all,您可以使用Feature type: all Element type: geometry.fill进行更具体的操作

3 个答案:

答案 0 :(得分:3)

我实现了信仰的飞跃并为"featureType":"areaOfInterest"设置了修饰符,令人惊讶的是它有效!!您可以使用areaOfInterest作为要素类型来定位样式,就像使用任何其他要素类型一样。

我设置了这种风格并获得了以下结果:

{
  "featureType":"areaOfInterest",
  "stylers":[
    {"saturation" : -100},
    {"lightness"  : 25},
    {"visibility" : "simplified"}
  ]
}

请注意,此样式适用于gmaps4rails gem插件,语法可能因您的应用程序而异。

在: enter image description here

在: enter image description here

答案 1 :(得分:1)

要真正“隐藏”感兴趣的区域:首先在all几何上设置颜色,然后通过指定水,公园,道路等的颜色来覆盖该设置。

代码示例:

var myStyle = [
    {featureType: "all", elementType: "geometry.fill", stylers: [{color: "#CCCCCC"}]},
    {featureType: "water", elementType: "geometry", stylers: [{hue: "#99CCFF"}, {lightness: 30}, {saturation: 50}]},
    {featureType: "road", elementType: "geometry", stylers: [{color: "#eeeeee"},{lightness: 30},{visibility: "simplified"}]},
    {featureType: "landscape.natural", elementType: "geometry", stylers: [{color: "#c4d7cd"}]},
    {featureType: "poi.park", elementType: "geometry", stylers: [{color: "#b4d9c6"}]},
];

答案 2 :(得分:0)

我采用了RSmithlal代码,并对其进行了少许修改,使其仅针对覆盖感兴趣区域的叠加色。这样我可以使标签颜色保持不变:

{
  featureType:'areaOfInterest',
  elementType: 'geometry',
  stylers:[
    {saturation : -100}
  ]
}