Morning,
I have recently been updating metadata on hosted feature services on AGOL.
When I try and add an extent for a bounding box using the 'current features in layer' option the bounding box itself is accurate but the coordinates referenced are not accepted. To get around this I need to adjust the bounding a minor amount and then coordinates update to a format that is accepted.
Is this the expected behaviour? Has anyone else noticed or come across this before?
See attachment for reference.
Thanks,
Andy
Hi @AndrewHankinson,
Yes, you can do this. Use featureLayer.queryExtent() to get the bounding box of filtered or visible features, then use view.goTo(extent) to zoom the map. Works well in custom widgets or embedded JS logic.
If you want something static or repeatable, use Minimum Bounding Geometry in ArcGIS Pro to create envelopes, then publish and use them in your app.
Dynamic = JS/API. Static = preprocessed in Pro.
Regards,
Venkat
Thanks for the response @VenkataKondepati , but I don't think that answers my question. The issue is when I apply a bounding box in AGOL the coordinates are not accepted as they are and I need to manually adjust the bounding box to correct the coordinates.
Absolutely. I understand the issue better now. You're looking to apply the bounding box generated from current features, right?
In ArcGIS Online, there's no out-of-the-box tool that dynamically captures the extent of selected or filtered features and applies it as a bounding box. But you can achieve this with two effective approaches:
Script it via the REST API or Web Map custom JSON
Use the query endpoint for your feature layer to get the extent of the current features.
Then set that extent (minx, miny, maxx, maxy) in your app or web map JSON to zoom or filter.
Pre-generate it in Pro using Minimum Bounding Geometry
Run that tool to create an envelope (polygon) representing each feature set.
Publish that as a hosted layer, then use it to zoom or filter.
Dynamic extent control requires scripting or custom apps. AGOL’s default UI doesn’t grab extents and apply filters automatically.
Let me know if you'd like a REST snippet or sample app code to do this.
Regards,
Venkat
Ok, well in the overview page of the layer, when you click on edit metadata there is an option to add an geographic extent and you can select this extent by the current features in the layer. So if that doesn't apply the bounding box generated from current features, what does it do?