如何将Google地图设置为双色地图? [英] How to style Google Maps as a two tone coloured map?

查看:139
本文介绍了如何将Google地图设置为双色地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google Maps API创建双色调地图。我已经尝试使用此向导创建自定义代码,但是当您放大地图时,可以看到某些区域(我不确定它们是白色还是绿色)。我想知道是否有一个快捷方式只需指定一种颜色的土地和一种水。

I'm trying to create a two tone map using Google Maps API. I've tried creating custom code using this wizard, but when you zoom into the map you can see certain areas (I'm not sure what they are) in white or green. I was wondering if there was a shortcut for specifying just one colour for land and one for water.

这是我的造型代码。

var styles = [
            {
                featureType: "water",
                elementType: "geometry",
                stylers: [
                    { color: '#193a70' },
                    { visibility: "on" }
                ]
            },{
                featureType: "landscape",
                 elementType: "geometry.fill",
                stylers: [
                    { "color": "#2c5ca5" }
                ]


            }
        ];

JSFiddle中的示例

推荐答案

更新了JSFiddle

下面是修复,我错过了'兴趣点'或'poi'以及其他各种元素。

Here is the fix, I was missing 'points of interest' or 'poi' and various other elements.

    var styles = [
            {
                featureType: "water",
                elementType: "all",
                stylers: [
                    { color: '#193a70' },
                    { visibility: "on" }
                ]
            },
            {
             featureType: "road",
              stylers: [
               { "visibility": "off" }
                  ]
                 },
          {
              featureType: "transit",
   stylers: [
   { "visibility": "off" }
      ]
    },{
       featureType: "administrative",
 stylers: [
   { "visibility": "off" }
    ]
 },  {
    featureType: "landscape",
                 elementType: "all",
                stylers: [
                    { "color": "#2c5ca5" }
                ]
                },{
                featureType: "poi",
                 stylers: [
                 { "color": "#2c5ca5" }

                ]
            },
            {
     elementType: "labels",
stylers: [
  { "visibility": "off" }
]
}
        ];

这篇关于如何将Google地图设置为双色地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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