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)
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<SPAN class="punctuation token">.</SPAN><SPAN class="token function">queryExtent</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">.</SPAN><SPAN class="token function">then</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN>response<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">{</SPAN> view<SPAN class="punctuation token">.</SPAN><SPAN class="token function">goTo</SPAN><SPAN class="punctuation token">(</SPAN>response<SPAN class="punctuation token">.</SPAN>extent<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN> <SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
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.
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.
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.