This seems like it should be very easy to do, but I am unable to click on a point and have the map recognize that I have clicked on the point. I first tried just creating a simple point, setting the query out fields to "*" and the spatial relationship to "INTERSECT". That didn't work so now I've been trying to create a polygon around where I click and setting the spatial relationship to both "WITHIN" and "CONTAINS" (two separate tries), I've also tried using an envelope instead of a polygon to no avail.
I have tried using this example directly and it works with the given map because the features are polygons, however when I change the URL's to my feature server (which is all points) it no longer does anything when I click, the length of the results array is zero.
Here is the code for my current attempt using an envelope (I left my comments in where I tried making a polygon as well) inside my OnSingleTapListener:
clicked = mMapView.toMapPoint(v1, v2); int dimens = mMapView.getExtent().getDimension(); double pixW = dimens / mMapView.getWidth(); double tolerance = 10 * pixW; Envelope env = new Envelope(clicked, tolerance, tolerance); Query query = new Query(); query.setGeometry(env); query.setOutFields(new String[] {"*"}); //Polygon poly = new Polygon(); //double x = clicked.getX(); //double y = clicked.getY(); //poly.startPath(x-2.0, y+2.0); //poly.lineTo(x+2.0, y+2.0); //poly.lineTo(x+2.0, y-2.0); //poly.lineTo(x-2.0, y-2.0); //poly.lineTo(x-2.0, y+2.0); query.setSpatialRelationship(SpatialRelationship.WITHIN); query.setInSpatialReference(mMapView.getSpatialReference()); featLayers[0].selectFeatures(query, ArcGISFeatureLayer.SELECTION_METHOD.NEW, Does anyone have any idea why this would not work when the exact same method works for other features that aren't points? The example also has me using an ArcGISDynamicMapServerLayer, is this necessary? I have tried it both with and without this layer although I prefer it without because the layer loads slowly and makes the map look worse.
أكثر...
I have tried using this example directly and it works with the given map because the features are polygons, however when I change the URL's to my feature server (which is all points) it no longer does anything when I click, the length of the results array is zero.
Here is the code for my current attempt using an envelope (I left my comments in where I tried making a polygon as well) inside my OnSingleTapListener:
clicked = mMapView.toMapPoint(v1, v2); int dimens = mMapView.getExtent().getDimension(); double pixW = dimens / mMapView.getWidth(); double tolerance = 10 * pixW; Envelope env = new Envelope(clicked, tolerance, tolerance); Query query = new Query(); query.setGeometry(env); query.setOutFields(new String[] {"*"}); //Polygon poly = new Polygon(); //double x = clicked.getX(); //double y = clicked.getY(); //poly.startPath(x-2.0, y+2.0); //poly.lineTo(x+2.0, y+2.0); //poly.lineTo(x+2.0, y-2.0); //poly.lineTo(x-2.0, y-2.0); //poly.lineTo(x-2.0, y+2.0); query.setSpatialRelationship(SpatialRelationship.WITHIN); query.setInSpatialReference(mMapView.getSpatialReference()); featLayers[0].selectFeatures(query, ArcGISFeatureLayer.SELECTION_METHOD.NEW, Does anyone have any idea why this would not work when the exact same method works for other features that aren't points? The example also has me using an ArcGISDynamicMapServerLayer, is this necessary? I have tried it both with and without this layer although I prefer it without because the layer loads slowly and makes the map look worse.
أكثر...