扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:dlwang2002 来源:博客园 2007年11月3日
关键字: VirtualEarth 开发地图 程序
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
<script src="http://dev.virtualearth.net/mapcontrol/v3/mapcontrol.js"></script> |
<div id='myMap' style="position:absolute; width:400px; height:400px;"></div> |
<script> var map = null; function GetMap() { map = new VEMap('myMap'); map.LoadMap(); } </script> |
1 function FindElvis() 2 { 3 map.Find('elvis','Las Vegas, NV','1',onFindResults); 4 } 5 function onFindResults(findResults) 6 { 7 var results="Find Results:\n"; 8 for (r=0; r<findResults.length; r++) 9 { 10 results+=findResults[r].Name + ", " + findResults[r].Description+"\n"; 11 } 12 alert(results); 13 } 14 |
1 function onMapClick(e) 2 { 3 var pinID = 3;//注意,id不能重复. 4 var pin = new VEPushpin( 5 pinID, 6 e.view.LatLong, 7 null, //这里可以是自己的图片 8 'My pushpin', 9 'This is pushpin number '+pinID 10 ); 11 12 map.AddPushpin(pin);//怎么保存这些数据?自己创建数据表 13 14 } |
DrawPoly 1 function DrawPoly() 2 { 3 var points = new Array( 4 new VELatLong(45.01188,-111.06687), 5 new VELatLong(42.01534,-104.06324), 6 new VELatLong(42.01929,-104.06), 7 new VELatLong(41.003,-111.05878), 8 new VELatLong(47.01188,-111.06687) 9 ); 10 11 poly = new VEPolyline('1',points); 12 poly.SetWidth(3); 13 poly.SetColor(new VEColor(0,150,100,100)); 14 map.AddPolyline(poly); 15 map.SetMapView(points); 16 } |
function onMapClick(e) { alert(e.view.LatLong.Latitude+';'+e.view.LatLong.Longitude ); } |
1 DataSet pins = Manager.DataManager.GetDataSet(sql + " where ViewPathID=" +key); 2 for (int i = 0; i < pins.Tables[0].Rows.Count; i++) 3 { 4 DataRow row = pins.Tables[0].Rows[i]; 5 string pid = row["PinID"].ToString(); 6 string vELatLong = String.Format("new VELatLong({0},{1})", row["Latitude"].ToString(), row["Longitude"].ToString()); 7 string userImg = "null";//String.Format( "'{0}'", row["ImgCard"].ToString()); 8 string pinName = String.Format("'{0}'", row["Name"].ToString()); 9 string pinDes = String.Format("'{0}'", row["Description"].ToString()); 10 string script = ""; 11 script += "<script type='text/javascript' language='javascript'> " + "\r\n";// 12 script += " var a=1; " + "\r\n"; 13 script += String.Format(" var pin=new VEPushpin({0},{1},{2},{3},{4}); ", pid, vELatLong, userImg, pinName, pinDes) + "\r\n"; 14 script += " map.AddPushpin(pin); " + "\r\n"; 15 //script += " alert('got'); " + "\r\n"; 16 script += "</script> " + "\r\n"; 17 18 this.Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowPin_" + pinName, script); |
function GetMap() { map = new VEMap('myMap'); map.LoadMap(); map.FindLocation('JiNan,China');//for default place //上边两句可以替换成 //map.LoadMap(new VELatLong(36.654097,116.968688),8);//这样可以直接加载默认页面,减少一次加载。 } function FindLoc() { map.FindLocation(document.getElementById('txtWhere').value); //map.SetZoomLevel(4); } function DeleteAllPushpins() { map.DeleteAllPushpins(); } function DeleteAllPolylines() { 应用:<body onload="GetMap();"> 地图:<div id='myMap' style="position: relative; width: 600px; height: 500px;"></div> |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者