Use URL Parameter to Zoom to Feature?

4450
22
Jump to solution
03-09-2022 11:32 AM
Labels (1)
JessicaWeinberg
New Contributor III

The Interactive Legend Instant App allows the use of URL parameters, but I can only figure out how to use them to highlight a feature/open its pop-up. How can I get it to also zoom in to that feature specified in the URL?

Basically, I'm looking for functionality equivalent to what's available in the Basic Viewer Configurable App, since it seems like Configurable Apps are being retired. If it isn't to be found in Instant Apps, is there another App I should try?

Tags (1)
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor

In the meantime you can use the level url param to specify the zoom level you'd like the app to zoom to when it loads. Here's an example of that url param in action: 

https://jsapi.maps.arcgis.com/apps/instant/media/index.html?appid=0696bb9aa10e42ab9860fd48be04517c&l...

View solution in original post

0 Kudos
22 Replies
KellyHutchins
Esri Frequent Contributor

We do have this capability in some apps like Media but I think that is what you were referring to when you said it opened the popup and highlighted the feature correct?  Here's an example:

https://jsapi.maps.arcgis.com/apps/instant/media/index.html?appid=0696bb9aa10e42ab9860fd48be04517c&l...

We can look at enhancing this capability to allow an option to zoom to the selected feature in a future release. Thank you for the feedback. 

 

BrightonC
New Contributor II

Thank you for looking into making the custom parameters available on more apps, local government worker. I love the sidebar app, love the pop-up populating the sidebar but really wish there was a way to have the item in question selected on the URL.

0 Kudos
KellyHutchins
Esri Frequent Contributor

In the meantime you can use the level url param to specify the zoom level you'd like the app to zoom to when it loads. Here's an example of that url param in action: 

https://jsapi.maps.arcgis.com/apps/instant/media/index.html?appid=0696bb9aa10e42ab9860fd48be04517c&l...

0 Kudos
CMV_Erik
Occasional Contributor

Should this also work with the Sidebar app? The center and level parameters seem to be ignored for me in Sidebar, but work as expected if I use them directly against the underlying map. The find parameter works in either one.

0 Kudos
KellyHutchins
Esri Frequent Contributor
0 Kudos
CMV_Erik
Occasional Contributor

Hello @KellyHutchins ,

Is the jsapi. prefix important? My app is secured and accessed via SAML users, so I normally put my organization there; if I don't include my organization, it doesn't recognized the logged in AGOL user, and the login prompt that comes up doesn't offer a choice for organization.

I notice you also used a a license parameter which I'm not familiar with; maybe that could help?

My app isn't shared with the public, but here's the URL minus our organization name: https://redacted.maps.arcgis.com/apps/instant/sidebar/index.html?appid=20b295f188eb43fd9e7da9e31ccd4...

 

0 Kudos
KellyHutchins
Esri Frequent Contributor

The JSAPI isn't important its just the org name. I don't have a license param added? Just level and center. Can you try enabling the share component in your app?  If you do that you can zoom to the location where you want to map then use share to copy the url - the share component will generate a url with the center,level for that zoom location. 

 

https://www.arcgis.com/apps/instant/sidebar/index.html?center=-118.1246;34.0892&level=14

0 Kudos
CMV_Erik
Occasional Contributor

RE: license: I must have been looking at your earlier post; I see now it wasn't in the most recent.

Thanks for your replies. It seems to be either a combination of parameters or this map/app in particular. I created a new generic app and can't replicate the problem. If I specify the original appid, the find parameter works, but the level parameter is ignored. I suspect this is too specific to my app to hijack this thread; I will troubleshoot on my own and ask elsewhere if needed.

Thanks

0 Kudos
KellyHutchins
Esri Frequent Contributor
Are there any errors in the developer console? I wonder if its due to the spatial reference in your app?
0 Kudos