日期:2014-05-20 浏览次数:20506 次
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <head id="Head1" runat="server"> <title>google map</title> <script src="http://maps.google.com/maps?file=api&v=2&key=abcdefg" type="text/javascript"></script> <script type="text/javascript"> //<![CDATA[ function load() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById("map")); //初始化一个地图实例 map.addControl(new GLargeMapControl());//全能控件 map.addControl(new GScaleControl());//比例尺 map.addControl(new GMapTypeControl());//允许用户在地图类型之间切换 map.setCenter(new GLatLng(35.745346,114.291375), 12); //设置地图中心的坐标,中国经纬度及放大倍数 map.enableDoubleClickZoom();//双击可以放大 } var jingdu= new Array(); var weidu= new Array(); var id=new Array(); var num=new Array("01","01","03","04","05","06","07","08","09"); var number=<%=number%>; <% for(int i=0;i<number;i++){ %> jingdu.push(<%=ln[i]%>); weidu.push(<%=la[i]%>); id.push(<%=id[i] %>); <% } %> var myicon = new GIcon();//创建新图标 myicon.iconSize = new GSize(27, 27); myicon.shadowSize = new GSize(45, 37); myicon.iconAnchor = new GPoint(9, 34); myicon.infoWindowAnchor = new GPoint(9, 2); myicon.shadow = "http://google-maps-icons.googlecode.com/files/shadow.png";//指定图标阴影图片 <% for(int k1=0;k1<number;k1++){ %> <% if(k1<=8) { %> myicon.image="http://google-maps-icons.googlecode.com/files/red0"+(<%=k1%>+1)+".png ";//指定图标图片 <% } %> <% else { %> myicon.image="http://google-maps-icons.googlecode.com/files/red"+(<%=k1%>+1)+".png "; <% } %> var gPointCZ; var gMarkCZ; //======================================================================== gPointCZ=new GLatLng(weidu[<%=k1 %>],jingdu[<%=k1%>]); gMarkCZ<%=k1%>=new GMarker(gPointCZ,{icon:myicon,title:"第"+(<%=k1%>+1)+"号点,点击查看更多信息"}); map.addOverlay(gMarkCZ<%=k1%>); //======================================================================== <% } %> } </script> </head> <body style="background-color:#F4FFE4" onload="load()" onunload="GUnload()"> <form id="form1" runat="server"> <div id="map" style="width: 1200px; height: 500px; position: static;"><!--这里放置地图实例,可以设置显示地图的大小--></div> </form> </body> </html>