使用這些api,即使一個門外漢也可以為自己的網(wǎng)站添加地圖。
下面的代碼,將會創(chuàng)建一個簡單的地圖網(wǎng)頁。如:
<html xmlns=" >
<head runat="server">
<title>地圖測試</title>
<script language="javascript" src="</head>
<body>
<form id="form1" runat="server">
<div id="myMap" style="position:relative; width:400px; height:300px;"></div>
<script language="javascript">
var maps = new LTMaps( "myMap" ); //LTMaps類有一個參數(shù),是該地圖所在div的name
maps.cityNameAndZoom( "beijing" , 5 );
var c = new LTSmallMapControl(); //簡單的放大縮小條
maps.addControl(c);
var point = new LTPoint( 11640969 , 3989945 );//北京
var marker = new LTMarker( point ); //一個標(biāo)記
maps.addOverLay( marker ); //將標(biāo)記覆蓋到地圖涂層上
var text = new LTMapText( marker );
text.setLabel( "我的位置" );
maps.addOverLay( text );
</script>
</form>
</body>
</html>
詳細(xì)的API說明在http://api.51ditu.com/docs/index.html可以查詢。

51API架構(gòu)
posted on 2009-02-11 20:25
ronliu 閱讀(373)
評論(0) 編輯 收藏 引用