现在的位置: 首页 > 综合 > 正文

ADF JavaScript获取地图坐标及与屏幕坐标的互转

2012年06月12日 ⁄ 综合 ⁄ 共 463字 ⁄ 字号 评论关闭

//在地图上单击画点

var map = $find('Map1');
map.getGeometry(ESRI.ADF.Graphics.ShapeType.Point, usePoint, null, 'red', '#0000FF', 'pointer', true);

 

//获取鼠标点击的位置的地图坐标

function usePoint(clickPoint)
{

  //地理坐标转到屏幕坐标
  var screenPoint=map.toScreenPoint(clickPoint);

  //获取屏幕坐标的X和Y分量

  var screenX=screenPoint.offsetX;

  var screenY=screenPoint.offsetY;

}

 

//屏幕坐标转到地理坐标

function ToMapXY(screenX,screenY)
{
   var map = $find('Map1');

   //返回 ESRI.ADF.Geometries.Point 类型的点
   var mapPoint=map.toMapPoint(screenX,screenY);

}

抱歉!评论已关闭.