![](/img/trans.png)
[英]When cutting a polygon with a polyline the geometry engine will group certain peices together?? Arcgis javascript api
[英]Arcgis javascript api-Getting polygon geometry
我正在使用ArcGis javascript API 3.2。 我有一张地图,上面有一层。 如何获得发生鼠标单击事件的多边形几何?
不仅是多边形ID,执行此操作还可以从地图服务中获取任何参数...
1)通过传递MapService作为参数来创建一个新的IdentifyTask()。
identifyTask = new esri.tasks.IdentifyTask("<Map Service URL should go here>");
2)创建一个新的IdentifyParameters()并设置以下属性。
identifyParams = new esri.tasks.IdentifyParameters();
identifyParams.tolerance = 2;
identifyParams.returnGeometry = true;
identifyParams.layers = esri.tasks.IdentifyParameters.LAYER_OPTION_ALL;
identifyParams.layerIds = [0,1,2,3,4];
identifyParams.sr=map.spatialreference;
identifyParams.width = map.width;
identifyParams.height = map.height;
3)鼠标单击时应调用一种方法。 你可以那样做
dojo.connect(map, "onClick", uponClick);
4)单击多边形时,将调用onClick()方法。 在onClick()方法内部,通过传递identifyParams作为参数来调用identifyTask.execute。
function uponClick(evt){
identifyParams.geometry = evt.mapPoint;
identifyParams.mapExtent = map.extent;
identifyTask.execute(identifyParams, function(result) {
for(var i=0; i<result.length; i++){
polyId=result[i].feature.attributes["UNIQPOLYID"];
}//end of for
});//end of execute
}//end of uponClick
UNIQPOLYID是地图服务将返回的那些方法之一。
您可以在此链接中找到详细的示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.