我正在尝试按照有关如何设置谷歌地图样式的教程进行操作,但样式不起作用,仅在屏幕上显示一个灰色方块(我创建的 div)。这是我正在使用的代码:
<!DOCTYPE html>
<html>
<head>
<style>
#map_canvas {
width: 500px;
height: 500px;
background-color: #CCC;
}
</style>
<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
function initialize() {
var styles = [
{
featureType: 'road',
elementType: 'geometry',
stylers: [
{ color: '#000000' },
{ weight: 1.6 }
]
}, {
featureType: 'road',
elementType: 'labels',
stylers: [
{ saturation: -100 },
{ invert_lightness: true }
]
}, {
featureType: 'landscape',
elementType: 'geometry',
stylers: [
{ hue: '#ffff00' },
{ gamma: 1.4 },
{ saturation: 82 },
{ lightness: 96 }
]
}, {
featureType: 'poi.school',
elementType: 'geometry',
stylers: [
{ hue: '#fff700' },
{ lightness: -15 },
{ saturation: 99 }
]
}
];
var styledMap = new google.maps.styleMapType(styles,{name: "styled Map"});
var map_canvas = document.getElementById('map_canvas');
var map_options = {
center: new google.maps.LatLng(44.5403, -78.5463),
zoom: 8,
mapTypeControlOptions: {
mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'map_style']
}
}
var map = new google.maps.Map(map_canvas, map_options);
map.mapTypes.set('map_style', styledMap);
map.setMapTypeId('map_style');
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map_canvas">
</div>
</body>
</html>
谁能帮我?