private function findAddressPoint(geom:Geometry):void { var q:Query = new Query(); q.geometry = geom; q.spatialRelationship = Query.SPATIAL_REL_CONTAINS; q.returnGeometry = true; q.outFields = ["*"]; var task:QueryTask = new QueryTask(); task.url = "http://svr-met-gisdev1:8399/arcgis/rest/services/M4/GIS_MasterMap/MapServer/1"; task.execute(q, new AsyncResponder(onResult, onFail)); }
is there a nice quick easy way to add a 5px tolerance around the point thats clicked?
var q:Query = new Query(); if (yourgeometry is MapPoint) { var mappoint:MapPoint = yourgeometry as MapPoint; var newextent:Extent = new Extent(); // not a buffered point, but it works var delta:Number = 10; newextent.minx = mappoint.xvalue -delta; newextent.miny = mappoint.yvalue -delta; newextent.maxx = mappoint.xvalue +delta; newextent.maxy = mappoint.yvalue +delta; q.geometry = newextent; } else { q.geometry = yourgeometry; }
private function createExtentAroundMapPoint(centerPoint:MapPoint, tolerance:Number):Extent { var screenPoint:Point = map.toScreen(centerPoint as MapPoint); var upperLeftScreenPoint:Point = new Point(screenPoint.x - tolerance, screenPoint.y - tolerance); var lowerRightScreenPoint:Point = new Point(screenPoint.x + tolerance, screenPoint.y + tolerance); var upperLeftMapPoint:MapPoint = map.toMap(upperLeftScreenPoint); var lowerRightMapPoint:MapPoint = map.toMap(lowerRightScreenPoint); return new Extent(upperLeftMapPoint.x, upperLeftMapPoint.y, lowerRightMapPoint.x, lowerRightMapPoint.y, map.spatialReference); }