我可以在地图上获取点击的经纬度坐标,但是我想在点击的时候自动添加标记以及信息窗口,请问该如何操作,谢谢

0 views
Skip to first unread message

thinkja...@gmail.com

unread,
May 17, 2006, 5:06:11 AM5/17/06
to 灵图地图接口讨论区
如题,谢谢!

程序清单如下:

<div id="myMap" style="position:relative; width:800px;
height:600px;"></div>

<script language="javascript">
var maps = new LTMaps( "myMap" );
maps.cityNameAndZoom( "beijing" , 5 );

var x,y;
var control = new LTMarkControl();
maps.addControl( control );
function getPoi()
{
var poi = control.getMarkControlPoint();
x = poi.getLatitude();
y = poi.getLongitude();
showPoi();
// alert( "纬度:" + x + "\n经度:" + y );
}
LTEvent.addListener( control , "mouseup" , getPoi );

function showPoi()
{
var point = new LTPoint( x/*11643648*/ , y/* 3983040*/ );//北京
var infoWin = new LTInfoWindow( point );
infoWin.setLabel( "<a href='http://www.51ditu.com'
target='_blank'>http://www.51ditu.com</a>" );
maps.addOverLay( infoWin );
alert( "纬度:" + x + "\n经度:" + y );
}

var point = new LTPoint( 11643648 , 3983040 );//北京
var infoWin = new LTInfoWindow( point );
infoWin.setLabel( "<a href='http://www.51ditu.com'
target='_blank'>http://www.51ditu.com</a>" );
maps.addOverLay( infoWin );

</script>

thinkja...@gmail.com

unread,
May 17, 2006, 5:08:47 AM5/17/06
to 灵图地图接口讨论区
Reply all
Reply to author
Forward
0 new messages