1

Using the ArcGIS Server JavaScript API, it's possible to specify an attribute query in the form of a layerDefinition against a Dynamic layer.

For example, the following query will restrict the layer to show only features where the population is greater than 5,000,000:

var layerDefinitions = [];
layerDefinitions[0] = "POPULATION > 5000000";
dynamicMapServiceLayer.setLayerDefinitions(layerDefinitions);

Is it possible to specify a bounding box in the layer definition?

That is, apply a spatial query in addition to any attribute query. The query should be based directly on the layer's geometry field (not an attribute derived from the geometry). Assume the data is stored in WGS84 and is "geometryType": "esriGeometryPoint".

0

Unfortunately, layerdefinitions do not support geometry operations. Some workarounds are:

  • Add X/Y attributes and filter on those
  • Add the service as separate FeatureLayer and code a custom renderer that excludes certain features
  • Use a QueryTask to get the ObjectID's of features within the bounding box, the set the layerdefinition to objectid in (1,2,...n)
-1

If that Geometry Point is stored, then, it must have an OBJECTID. You can just select it with a query like : OBJECTID = 1

Edit:

You could do a spatial intersect, using a polygon drawn with the coordinates you want as described here https://developers.arcgis.com/javascript/3/jsapi/polygon-amd.html#polygon3 and pass it to the query

var polygon = new Polygon([[50, 0], [150, 20], [150, -20], [50,0]]);
query.geometry = polygon;
query.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;

there are other spatial operations, maybe you'd prefer SPATIAL_REL_WITHIN https://developers.arcgis.com/javascript/3/jsapi/query-amd.html#constants

  • by "bounding box", I mean that I need to select features which fall within specified geographic coordinates, such as an extent. I won't know what the ObjectID of the point is, or even if it exists. – Stephen Lead Sep 27 '17 at 22:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.