fullExtent of featureLayer created from featureCollection

2943
3
Jump to solution
02-04-2013 07:55 AM
LukePhilips
New Contributor III
Hey,
I'm trying to get the fullExtent of a featureLayer that when first created is based on a featureCollection. As I use the featureLayer I'll be editing it, adding/removing points based on other service queries. Every time I add data I want to zoom the map to the extent of the points on the map, which I would expect to be the featureLayer.fullExtent values. However, this extent value it typically undefined. Here is an example:
http://help.arcgis.com/en/webapi/javascript/arcgis/jssamples/#sample/fl_featurecollection
0 Kudos
1 Solution

Accepted Solutions
DianaBenedict
Occasional Contributor III
The esri namespace methods provides a utility that will return the extent of a graphic array

http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/#namespace_esri/esri.graphicsExtent

esri.graphicsExtent(graphics)

Maybe this can help you.  I use it to zoom to selected features/grpahics on a map.

View solution in original post

0 Kudos
3 Replies
StephenLead
Regular Contributor III
Hi Luke,

I'm not sure whether there's a method or property to return this directly.

If not, you could iterate through the geometries in your feature collection and union the extents cumulatively. The end result would be the combined extent of all features.

Steve
0 Kudos
DianaBenedict
Occasional Contributor III
The esri namespace methods provides a utility that will return the extent of a graphic array

http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/#namespace_esri/esri.graphicsExtent

esri.graphicsExtent(graphics)

Maybe this can help you.  I use it to zoom to selected features/grpahics on a map.
0 Kudos
LukePhilips
New Contributor III
Thanks for both of your answers, using the graphicsExtent gets exactly what I need. I was thinking the featureLayer.fullExtent property http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/#FeatureLayer/fullExtent would have done that, but I guess not.
Thanks.
0 Kudos