鼠标点击完成标注示例 备注:请仔细阅读我们在click事件中的参数(point,button,marker)

0 views
Skip to first unread message

chenchen

unread,
Nov 8, 2006, 3:39:00 AM11/8/06
to 灵图地图接口讨论区
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JavaScript Maps API</title>

<!--1、引入JavaScript文件-->
<script language="javascript" src=" http://api.51ditu.com/js/maps.js
"></script>
</head>
<body>


<!--3、创建地图对象-->
<script language="javascript">
var toolTipLayer=document.createElement("DIV");
toolTipLayer.id="myMap";
toolTipLayer.style.position="absolute";
toolTipLayer.style.left="200px";
toolTipLayer.style.width="400px";
toolTipLayer.style.height="300px";
toolTipLayer.style.top="200px";
document.body.appendChild(toolTipLayer);
var maps = new LTMaps( "myMap" );

maps.cityNameAndZoom( "beijing" , 5 );


LTEvent.addListener( maps , "click" , b );

function
b(p)//p为鼠标单击事件传入的参数鼠标的位置相对于地图左上角的像素坐标
{
alert(p[0]);
alert(p[1]);
alert(p);
lpot=maps.getPointLatLng(p)//得到LTPOINT对象
var marker = new LTMarker( lpot);//产生标记
maps.addOverLay( marker );
alert("标记增加完成");
}
</script>
</body>
</html>

Reply all
Reply to author
Forward
0 new messages