arcgis js怎么点击要素时,怎么可以扩大供点击的范围???

有个功能是当我点击要素featurelayer上的某个点要素时,会出现一个效果,现在我想要点击这个要素的周围也可以起作用,或许会根据最近距离来判断选择最近的一个要素??不知道这个功能js怎么实现,还是设置要素的某个属性就好了
已邀请:

goldenlimit - Major in MIS and minor in GIS, graduated from University of Alabama. GIS is not a simply tool but a way of exploring the unknow

赞同来自: 谢军 吴悔

2种方法:
方法1:使用這個類 esri/tasks/IdentifyParameters 有一個tolerance的參數你可以控制精確度

identifyParams.tolerance = 3;
這個是相關的demo:
https://developers.arcgis.com/javascript/3/jssamples/find_popup.html
 
方法2:
用一個callback function 來更改你鼠標點擊要素的距離:
 
This has given me some luck.
function pointToExtent(map, point, toleranceInPixel) {
var pixelWidth = map.extent.getWidth() / map.width;
var toleraceInMapCoords = toleranceInPixel * pixelWidth;
return new esri.geometry.Extent( point.x - toleraceInMapCoords,
point.y - toleraceInMapCoords,
point.x + toleraceInMapCoords,
point.y + toleraceInMapCoords,
map.spatialReference );
}


"onClick"

dojo.connect(map,"onClick",function(evt){
var query = new esri.tasks.Query();
query.geometry = pointToExtent(map,evt.mapPoint,10);

這是一個很早之前的blog講了類似的方法:
https://blogs.esri.com/esri/arcgis/2010/02/08/find-graphics-under-a-mouse-click-with-the-arcgis-api-for-javascript/
 
希望對你有所幫助

要回复问题请先登录注册