arcgis JavaScript 获取鼠标在地图上移动的坐标

代码如下

//地图加载后,监听到鼠标移动或拖动事件
dojo.connect(map, "onMouseMove", showCoordinates);
dojo.connect(map, "onMouseDrag", showCoordinates);

//显示坐标的回调函数,参数是evt
function showCoordinates(evt) {
    document.getElementById("Coordinate").style.display = "block";
    //从事件中获取mapPoint
    var mp = evt.mapPoint;
    //显示鼠标坐标
    dojo.byId("info").innerHTML = "当前经纬度坐标:(" + mp.x + "," + mp.y + ")";
}

 

你可能感兴趣的:(JavaScript)