Hi Vitor Ribeiro,
You should be able to grab the extent from the layer object that is returned from a search:
Here's a sample code:
from arcgis.gis import GIS
gis = GIS("https://ABC.maps.arcgis.com", "USERNAME", "PASSWORD")
search_result = gis.content.search('title:LayerOfInterest', item_type = 'Feature Service')
if len(search_result) > 0:
layer = search_result #assuming we want the first layer.
Attached is a screenshot of the code running on my AGOL with the results displayed in the output.
Hope that helps.
This form works, but returns something empty.
These steps I followed to child Web Map with my desired information. The biggest problem is zooming to the extent of Filtered Layers.
- I created WebMap ()
- Add 2 layers to wb
- I gave a definitionExpression on my layers (as shown in print)
- Set up webmap_item_properties with title
- snippet and tags
- I finally saved the Web Map
Unfortunately the extent of the Map is too far away, showing the entire globe of the basemap. I would like to know if it is possible to zoom the moment you filter in definitionExpression?
Here's a screenshot of my Jupyter Notebook
In the empty line was my sql, but I had personal information and could not publish, but it was working
How are you publishing the web map and where are you viewing it from?
If using the map widget from Jupyter Notebook, you can configure the desired zoom level via the attribute zoomlevel
If you are using Publish Item, you can specify the extent in the layerInfo object.
Alternatively, you can always open up the web map in Portal/AGOL and change the extent/zoom and save the changes manually.
Hope that helps.