2

您好,我可以在更改样式地图的同时使水变暗,以便重置其他值。我想要的是一张像 MapTypeId.TERRAIN 这样的绿色景观和更深的水的地图。我可以设法让水变暗,现在也想要像 MapTypeId.TERRAIN 一样的绿色景观。你能推荐一个方法吗?谢谢

4

2 回答 2

4

目前,Google Styled Maps不能应用于默认类型以外的地图类型ROADMAP。2010 年 5 月 31 日,邮件列表中的一位 Google 员工证实了这一点:

但是,如果您只是想要一个带有深色水的绿色地形,您仍然可以将默认设置ROADMAP为如下所示:

aGoogle Maps Dark Water Style 演示

示例源代码:

<!DOCTYPE html>
<html> 
<head> 
   <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
   <title>Google Maps Dark Water Style Demo</title> 
   <script src="http://maps.google.com/maps/api/js?sensor=false" 
           type="text/javascript"></script> 
</head> 
<body> 
   <div id="map" style="width: 550px; height: 300px;"></div> 

   <script type="text/javascript"> 
     var darkStyle = [
       {
         featureType: "landscape",
         elementType: "all",
         stylers: [
           { visibility: "on" },
           { hue: "#1aff00" },
           { lightness: -17 }
         ]
       },{
         featureType: "water",
         elementType: "all",
         stylers: [
           { hue: "#1900ff" },
           { invert_lightness: true },
           { lightness: -56 },
           { saturation: 31 },
           { visibility: "simplified" }
         ]
       },{
         featureType: "administrative",
         elementType: "all",
         stylers: [
           { gamma: 0.82 },
           { visibility: "on" },
           { lightness: -18 },
           { hue: "#00ff4d" },
           { saturation: 27 }
         ]
       }
     ];

     var map = new google.maps.Map(document.getElementById('map'), {
       mapTypeControlOptions: {
         mapTypeIds: [
          'darkwater', 
          google.maps.MapTypeId.ROADMAP, 
          google.maps.MapTypeId.TERRAIN
         ]
       },
       center: new google.maps.LatLng(30, 0),
       zoom: 1,
       mapTypeId: 'darkwater'
     });

     map.mapTypes.set(
       'darkwater', new google.maps.StyledMapType(darkStyle, { 
         name: 'Dark' 
       })
     );
   </script> 
</body> 
</html>
于 2010-10-01T13:58:24.717 回答
-1

您可以使用此地图直观地设置地图样式:http: //gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html

于 2012-02-16T15:12:15.667 回答