Google Maps JavaScript API - 样式建筑

时间:2014-04-01 03:45:04

标签: javascript google-maps styles

这是我遇到的问题:

enter image description here

我有一个风格化的Google地图。我似乎无法让大学的建筑物像其他建筑物一样无色和抚摸。我在这里查看了文档:https://developers.google.com/maps/documentation/javascript/reference#MapTypeStyleFeatureType

并尝试了所有这些,但没有一个可以工作。

这是我的风格:

[
   {
      "featureType":"water",
      "elementType":"geometry",
      "stylers":[
         {
            "color":"#193341"
         }
      ]
   },
   {
      "featureType":"landscape",
      "elementType":"geometry.fill",
      "stylers":[
         {
            "color":"#2c5a71"
         }
      ]
   },
   {
      "featureType":"landscape",
      "elementType":"geometry.stroke",
      "stylers":[
         {
            "color":"#2c5a71"
         },
         {
            "lightness":-50
         }
      ]
   },
   {
      "featureType":"road",
      "elementType":"geometry",
      "stylers":[
         {
            "color":"#29768a"
         },
         {
            "lightness":-37
         }
      ]
   },
   {
      "featureType":"poi",
      "elementType":"geometry",
      "stylers":[
         {
            "color":"#406d80"
         }
      ]
   },
   {
      "featureType":"transit",
      "elementType":"geometry",
      "stylers":[
         {
            "color":"#406d80"
         }
      ]
   },
   {
      "elementType":"labels.text.stroke",
      "stylers":[
         {
            "visibility":"on"
         },
         {
            "color":"#3e606f"
         },
         {
            "weight":2
         },
         {
            "gamma":0.84
         }
      ]
   },
   {
      "elementType":"labels.text.fill",
      "stylers":[
         {
            "color":"#ffffff"
         }
      ]
   },
   {
      "featureType":"administrative",
      "elementType":"geometry",
      "stylers":[
         {
            "weight":0.6
         },
         {
            "color":"#1a3541"
         }
      ]
   },
   {
      "featureType":"poi",
      "elementType":"labels",
      "stylers":[
         {
            "visibility":"off"
         }
      ]
   },
   {
      "featureType":"poi.park",
      "elementType":"geometry",
      "stylers":[
         {
            "color":"#2c5a71"
         }
      ]
   },
   {
      "featureType":"landscape",
      "elementType":"geometry",
      "stylers":[
         {
            "hue":"#406d80"
         },
         {
            "gamma":1
         },
         {
            "lightness":1
         },
         {
            "saturation":0
         }
      ]
   },
   {
      "featureType":"poi",
      "elementType":"geometry",
      "stylers":[
         {
            "visibility":"off"
         }
      ]
   }
]

甚至可以改变那些建筑颜色吗?

1 个答案:

答案 0 :(得分:0)

地图上未进行样式设置的建筑物都显示室内地图。我想你想做的是设计室内地图。

不幸的是,我认为没有办法重新设计室内地图。我能找到的最接近的是:

Remove indoor maps from styled Google Maps

建议的解决方案是:

[
  {"stylers": [ {"visibility": "off" } ] },
  {"featureType": "water","stylers": [{"visibility": "on"} ] },
  {"featureType": "poi","stylers": [ {"visibility": "on"} ]},
  {"featureType": "transit","stylers": [{ "visibility": "on"}] },
  { "featureType": "landscape","stylers": [ { "visibility": "on" } ] },
  { "featureType": "road", "stylers": [{ "visibility": "on" } ] },
  { "featureType": "administrative",  "stylers": [{ "visibility": "on" } ] },
  /* followed by your style if you have specific styles
    , otherwise remove the last comma */

]