Filter ArcGISDynamicMapServiceLayer to get Imges

668
3
Jump to solution
06-25-2019 07:27 PM
HenryKo2
Occasional Contributor

Hi, I have a points ArcGISDynamicMapServiceLayer. In my JavaScript API code, is it possible to generate map images by using a geometry (such as a polygon) to intersect with the points?

What I want is to have a polygon as an input geometry, then get the intersecting points back as images - not features/graphics (so using a QueryTask or feature service will not satisfy the requirement). I want images and not graphics/features as potentially there could be almost millions of points.

I know you can use layer definitions on ArcGISDynamicMapServiceLayer but it is essentially a textual where-clause, not a geometry. I am hoping for something like this:

var myMapService = new ArcGISDynamicMapServiceLayer(url, {...});

myMapService.setLayerDefinitionWithGeometry(new Polygon(...)); // Similar to setLayerDefinition() but with geometry.

I am using JavaScript API 3.22 with ArcGIS for Server 10.6.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Henry,

   No there is no such ability as setting the definition expression by a geometry. But one way to do this is to use the geometry in QueryTask to query for object Ids and then use that to set the layers definition expression. If you are sometimes expecting a million results then you will have to consider the inverse of the queries where clause.

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Henry,

   No there is no such ability as setting the definition expression by a geometry. But one way to do this is to use the geometry in QueryTask to query for object Ids and then use that to set the layers definition expression. If you are sometimes expecting a million results then you will have to consider the inverse of the queries where clause.

HenryKo2
Occasional Contributor

Thanks Robert. Using ObjectID is definitely one option, although I need to find out if there are limits to how long the layer definition string would be and performance. Another option, which will take longer time to develop (we have a very tight deadline), is to do the intersect in the back-end (e.g. GP service), then store the intersected points IDs in a database table against a unique ID (e.g. username with timestamp), join this table with the map service, and filter the map service with definition expression using the unique ID.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Henry,

  Using a SQL "IN ( OID1, OID2)" Where clause will keep the size of the string down and is more works better than an  Where using OR. Just FYI.