<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MapType_Overlay.aspx.cs" Inherits="Samples.Overlays.MapType_Overlay" %> <!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&language=zh-CN"></script> <script language="javascript" type="text/javascript"> //设置层次提示大小 function CoordMapType(tileSize) { this.tileSize = tileSize; } //叠加层地图原型 CoordMapType.prototype.getTile = function(coord, zoom, ownerDocument) { var div = ownerDocument.createElement("DIV"); div.innerHTML = coord; div.style.width = this.tileSize.width + "px"; div.style.height = this.tileSize.height + "px"; div.style.fontSize = "10"; div.style.borderStyle = "solid"; div.style.borderWidth = "1px"; div.style.borderColor = "#AAAAAA"; return div; }; var map; var chicago = new google.maps.LatLng(41.850033, -87.6500523); function initialize() { var Options = { zoom: 10, center: chicago, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("maps"), Options); //创建叠加层地图并添加到地图面板上 map.overlayMapTypes.insertAt(0, new CoordMapType(new google.maps.Size(256, 256))); } //将地图初始化函数绑定到window的load事件 google.maps.event.addDomListener(window, "load", initialize); </script> </head><body> <form id="form1" runat="server"> <div id="maps"> </div> </form></body></html>