地图坐标转屏幕坐标
public System.Drawing.Point MapToScreenPoint(double mapX, double mapY)
{
ESRI.ArcGIS.ADF.Web.Geometry.Point adf_point = new ESRI.ArcGIS.ADF.Web.Geometry.Point(mapX, mapY);
ESRI.ArcGIS.ADF.Web.Geometry.TransformationParams transformationParameters = Map1.GetTransformationParams(ESRI.ArcGIS.ADF.Web.Geometry.TransformationDirection.ToScreen);
System.Drawing.Point screen_point = adf_point.ToScreenPoint(transformationParameters);
return screen_point;
}
脚本客户端处理
//在地图上单击画点
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);
}