FeatureLayer.fullExtent is null in JS API 4.3

1815
2
Jump to solution
03-31-2017 07:41 AM
janjermei
New Contributor III

Hi there, whenever I run the code :

 

layer.then(function(){

  view.extent = layer.fullExtent;

});

 

when layer is a FeatureLayer the full Extent is always null.

 

Is this a bug or a known issue ( can be tested with the sandbox example FeatureLayer)

0 Kudos
1 Solution

Accepted Solutions
KristianEkenes
Esri Regular Contributor

The fullExtent of the layer is determined by the service. So someone can publish a layer containing a fullExtent or one without one. If you want to ensure you are zooming to the fullExtent of your data, you can get this on the client by doing the following:

layer.queryExtent()
  .then(function(response){
     view.goTo(response.extent);
  });

That will ensure your view zooms to the extent of all features in the layer whether or not a fullExtent is present on the service.

View solution in original post

2 Replies
ThomasSolow
Occasional Contributor III

Is this the example you're referring to? ArcGIS API for JavaScript Sandbox

I see a fullExtent being set properly once the layer has loaded.

My understanding is that fullExtent is not calculated in the client, rather it is passed from the service.  I would check your service and make sure it has a fullExtent.

If you're building a featureLayer in the client I doubt fullExtent will be calculated automatically.  In this case you may have to calculate it yourself by finding the smallest bounding box that contains all features.

KristianEkenes
Esri Regular Contributor

The fullExtent of the layer is determined by the service. So someone can publish a layer containing a fullExtent or one without one. If you want to ensure you are zooming to the fullExtent of your data, you can get this on the client by doing the following:

layer.queryExtent()
  .then(function(response){
     view.goTo(response.extent);
  });

That will ensure your view zooms to the extent of all features in the layer whether or not a fullExtent is present on the service.