Filtered FeatureLayer and ArcGISDynamicMapServiceLayer extent

2021
4
11-20-2013 12:05 PM
JamesVillanueva
New Contributor III
Is there a way to get the extent of a layer which uses  layer definitions/expression? By default, I only see the extent of the service. It seems like running a query to compile extent is a bad option. This seems exceedingly true when it has to be done on ArcGISDynamicMapServiceLayer which would require separate queries on each sublayer.
0 Kudos
4 Replies
JasonZou
Occasional Contributor III
After featLayer.setDefinitionExpression, try the below code:
var extLayer = esri.graphicsExtent(featLayer.graphics);
0 Kudos
JamesVillanueva
New Contributor III
This works fine when you're zoomed to full extent. However if your user is zoomed into a closer area, the graphics in the layer change due to the fact that your layer is managed. There is not a good way I have found to consistenly get the extent of all graphics in a layer filtered by expression other than running a query on the layer.
0 Kudos
JasonZou
Occasional Contributor III
What mode do you set when creating the feature layer? Try to use MODE_SNAPSHOT instead of the other two.
0 Kudos
JamesVillanueva
New Contributor III
I work with a lot of large datasets. This seems like it would degrade the performance of the system greatly. Plus, if you have a layer with a feature count over your feature threshold in your service, you would never see the other features when zoomed into other areas. It would be nice if the service was smart enough to provide you a filtered extent upon layer creation and updates to the extent if the service has changes commited to it. I really do appreciate the suggestions.
0 Kudos