这是一个完整的示例供您遵循:
我在这里添加了所有内容。
<!DOCTYPE html>
<html>
<head>
<title>Google Maps</title>
<style> #map-canvas { margin: 0; padding: 0; height: 400px; width: 100%; }
</style>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script>
function initialize() {
var styles = [
{
"featureType": "landscape",
"stylers": [
{ "color": "#ffffff" }
]
},{
"featureType": "road",
"stylers": [
{ "color": "#000000" }
]
},{
"featureType": "water",
"elementType": "geometry",
"stylers": [
{ "color": "#ffffff" }
]
},{
"featureType": "poi",
"stylers": [
{ "color": "#ffffff" }
]
}
];
google.maps.visualRefresh = true;
var styledMap = new google.maps.StyledMapType(styles,{name: "Styled Map"});
var mapDiv = document.getElementById('map-canvas');
var myOptions = {
zoom: 4,
center: new google.maps.LatLng(-25.363882, 131.044922),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(mapDiv, myOptions);
map.mapTypes.set('map_style', styledMap);
map.setMapTypeId('map_style');
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas">
</body>
</html>