<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Overlay_Icon_Complex.aspx.cs"
Inherits="Samples.Overlays.Overlay_Icon_Complex" %>
<!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 initialize() {
var Options = {
zoom: 10, center: new google.maps.LatLng(-33.9, 151.2), mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("maps"), Options);
setMarkers(map, beaches);
}
//图标数据对象数组
var beaches = [
['Bondi Beach', -33.890542, 151.273856, 4],
['Coogee Beach', -33.923036, 151.25902, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.2874782854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];
//创建并设置图标
function setMarkers(map, locations) {
//创建图标
var image = new google.maps.MarkerImage(
"../images/nei_24.gif",
new google.maps.Size(20, 32),
new google.maps.Point(0, 0),
new google.maps.Point(0, 32)
);
//创建阴影图标
var shadow = new google.maps.MarkerImage(
"../images/china.png",
new google.maps.Size(300, 320),
new google.maps.Point(0, 0),
new google.maps.Point(0, 32)
);
//外形
var shape = { coord: [1, 1, 1, 20, 18, 20, 18, 1],
type: "poly"
};
//遍历图标数据数组,创建图标
for (var i = 0; i < locations.length; i++) {
var beach = locations[i];
var LatLng = new google.maps.LatLng(beach[1], beach[2]);
var marker = new google.maps.Marker(
{
position: LatLng, map: map, shadow: shadow, icon: image, shape: shape, title: beach[0], zIndex: beach[3]
}
);
}
}
//将地图初始化函数绑定到window的load事件
google.maps.event.addDomListener(window, "load", initialize);
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="maps">
</div>
</form>
</body>
</html>
引用请说明出处