更改谷歌地图的颜色 [英] Change the colors of the google maps

查看:186
本文介绍了更改谷歌地图的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能使用新的Google地图JavaScript API将地图的颜色更改为具有类似此类的内容在浅蓝色面板下的地图 风格化的地图可能是你正在寻找的东西,



首先值得一提的是向导(注意在#9中,它应该是 styles $ b

https://mapstyle.withgoogle.com



以下是参考资料:

http://code.google.com/ apis / maps / documentation / javascript / reference.html#StyledMapType

http://code.google.com/apis/maps/documentation/javascript/styling.html



有一个样式化的地图示例在静态API
http://code.google.com / apis / maps / documentation / staticmaps /#StyledMaps


饱和度和亮度控制着外观。饱和度较低=颜色较少,亮度较高=较白

 <!DOCTYPE html> 
< html>
< head>
< style type =text / css>
html,body,#map_canvas {margin:0;填充:0;身高:100%}
< / style>
< script type =text / javascriptsrc =http://maps.googleapis.com/maps/api/js?sensor=false>< / script>
< script type =text / javascript>
var map;
var grayStyles = [
{
featureType:all,
stylers:[
{saturation:-90},
{lightness:50}
]
},
];
var mapOptions = {
center:new google.maps.LatLng(41.325663,19.8029607),
zoom:15,
styles:grayStyles,
mapTypeId:google。 maps.MapTypeId.ROADMAP
};

函数initialize(){
map = new google.maps.Map(document.getElementById(map_canvas),mapOptions);
}

google.maps.event.addDomListener(window,'load',initialize);
< / script>
< / head>
< body>
< div id =map_canvas>< / div>
< / body>
< / html>


is it possible with the new Google maps javascript API to change the colors of the maps to have something like this map under the light blue panel

解决方案

Styled maps might be what you are looking for,

It's worth mentioning the wizard first (note that in #9, it should be styles, not style)

https://mapstyle.withgoogle.com

These are references:

http://code.google.com/apis/maps/documentation/javascript/reference.html#StyledMapType

http://code.google.com/apis/maps/documentation/javascript/styling.html

There's an example of a styled map in the static API http://code.google.com/apis/maps/documentation/staticmaps/#StyledMaps

The saturation and lightness control the look. Less saturated = less color, more lightness = whiter

<!DOCTYPE html>
<html>
  <head>
    <style type="text/css">
      html, body, #map_canvas { margin: 0; padding: 0; height: 100% }
    </style>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">
      var map;
      var grayStyles = [
        {
          featureType: "all",
          stylers: [
            { saturation: -90 },
            { lightness: 50 }
          ]
        },
      ];
      var mapOptions = {
        center: new google.maps.LatLng(41.325663, 19.8029607),
        zoom: 15,
        styles: grayStyles,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      };

      function initialize() {
        map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
      }

      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </head>
  <body>
    <div id="map_canvas"></div>
  </body>
</html>

这篇关于更改谷歌地图的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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