<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MapType_Style_Sample.aspx.cs"
Inherits="Samples.Overlays.MapType_Style_Sample" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>样式化地图</title>
<style type="text/css">
#maps
{
height: 450px;
}
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script language="javascript" type="text/javascript">
var map;
var brooklyn = new google.maps.LatLng(40.6743890, -73.9455);
function initialize() {
//将道路更改为黄色,住宅区更改为褐色
var stylez = [
{ featureType: "road.local", elementType: "geometry", stylers: [{ hue: "#f0000" },
{ saturation: 100}]
},
{ featureType: "landscape", elementType: "geometry", stylers: [{ hue: "#000000" }, { saturation: 75 },
{ lightness: -100}]
}
];
var Options = { zoom: 11, center: brooklyn };
map = new google.maps.Map(document.getElementById("maps"), Options);
var styledMapOptions = {
map: map, name: "Hip-Hop"
}
//实例化样式器对象
var jayzMapType = new google.maps.StyledMapType(stylez, styledMapOptions);
//设置地图样式器
map.mapTypes.set("hiphop", jayzMapType);
//设置地图样式
map.setMapTypeId("hiphop");
}
//将地图初始化函数绑定window的load事件
google.maps.event.addDomListener(window, "load", initialize);
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="maps">
</div>
</form>
</body>
</html>