您好 我可以在改变风格的地图的同时使水变暗,以便重置其他值。我想要的是一张绿色景观的地图,如MapTypeId.TERRAIN和深色水。我可以管理让水更暗,现在也想要MapTypeId.TERRAIN具有的绿色景观。你能推荐一种方式吗?感谢
答案 0 :(得分:4)
目前,Google Styled Maps无法应用于默认ROADMAP
类型以外的地图类型。 2010年5月31日,Google员工在邮件列表中确认了这一点:
但是,如果你只是想要一个带有黑水的绿色地形,你仍然可以设置默认的ROADMAP
样式,如下所示:
示例源代码:
<!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>
答案 1 :(得分:-1)