asp.net添加电子地图
http://api.51ditu.com/ 这里有免费地图接口,从里面设置一下地理位置,最后获得接口代码,粘贴到自己网站里就好了
例子:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<div>
<!--引入JavaScript文件-->
<script language="JavaScript" src="http://api.51ditu.com/js/maps.js" type="text/javascript"></script>
<!--创建一个DIV-->
<div id="maps" style="position:relative; width:500px; height:400px; border:black solid 1px;">
<div align="center" style="margin:12px;">
<a href="../mapsapi/help.html" target="_blank" style="color:#D01E14;font-weight:bolder;font-size:12px;">看不到地图请点这里</a>
</div>
</div>
<!--创建地图,并且给地图加个简易缩放控件-->
<script language="JavaScript" type="text/javascript">
var maps = new LTMaps( "maps" );
maps.cityNameAndZoom( "shanghai" , 3 ); //城市代码(比如kunshan shanghai beijing等等)数字2代表详细级别(0-14)
var c = new LTSmallMapControl();
maps.addControl(c);
var point = new LTPoint( 11640969 , 3989945 ); //上海
var marker = new LTMarker( point );
maps.addOverLay( marker );
var text = new LTMapText( marker );
text.setLabel( "我的位置" );
maps.addOverLay( text );
</script>
</div>
</form>
</body>
</html>