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);
1 个回复
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
赞同来自: 谢军 、吴悔
方法1:使用這個類 esri/tasks/IdentifyParameters 有一個tolerance的參數你可以控制精確度
identifyParams.tolerance = 3;
這個是相關的demo:
https://developers.arcgis.com/javascript/3/jssamples/find_popup.html
方法2:
用一個callback function 來更改你鼠標點擊要素的距離:
這是一個很早之前的blog講了類似的方法:
https://blogs.esri.com/esri/arcgis/2010/02/08/find-graphics-under-a-mouse-click-with-the-arcgis-api-for-javascript/
希望對你有所幫助
要回复问题请先登录或注册