You may have been working with ArcGIS Web AppBuilder for some time now, and mainly see it as your interactive Web AppBuilding friend. But did you know you can easily swap out your web map from the application, by simply modifying the URL?
This could you be useful to you if you were creating a web application template for users and you wanted to quickly see how your application template would look, referencing a variety of maps. Or, if you wanted to promote the use of your web application to your users, in a way that showcases a variety of web maps.
You can do this quickly using a URL scheme. The scheme essentially adds the item ID value of the applicable web map, to your existing web application URL, using a key/value pair. The key is the “webmap” property, whilst the “value” references the web map via its ID.
Working with the URL Scheme to Swap Out a Web Map
After logging into your ArcGIS Online (AGOL) account, navigate to the Item Details page of a web application item that you want to use (via Content). You can either click ‘View Application’ or copy and paste the URL value (found at the lower right of the Item Details page) into a new browser tab. Your existing web application should appear.
From here open up another browser tab and go to the Item Details page of an alternate web map that you would like to use in your web application (via Content). Grab the item ID from the end of the content item’s URL (in the address bar of the web page), as shown below.
Now, switch back to the tab displaying the web application. The address bar will be displaying a URL of the form :
Add the below string to the end of your existing web application URL.
&webmap=[paste your web map item id here] For example: https://yourOrg.maps.arcgis.com/apps/webappviewer/index.html?id=97a56c4ea41d4a379d1e2d06f9373356&webmap=05de2fb7c116420cbfd2be9446da099b
Your Web AppBuilder web application should now be referencing the web map you have selected and all of its saved configurations (i.e. layers, popups, symbology etc.)!
Breaking down the URL components
Below is a breakdown of the URL scheme syntax used to change a web map within a Web AppBuilder web mapping application (in AGOL):
- yourOrg– This is your AGOL organizational short name.
- WEB_APP_ITEM_ID – This is your web application item ID
- ? – This symbol represents the start of the URL scheme query string
- & – Joins another key/value pair to the query string
- id= or webmap= – These represent a property key term, which is to be assigned
- WEB_MAP_ITEM_ID – This is your web map item ID
Notice then, the general pattern of the web app URL. First there is the specification of the web app :
followed by a key/value pair specification:
A succession of key/value pairs may be appended, as shown the below example. The first key specifies a web map, the second specifies the coordinate location, over which the web map will be centred.
What are the benefits of doing this?
- CONSISTENCY – It will allow the user to use different maps within the web application, honoring the same template (widgets, themes etc.). This a huge benefit for consistent branding.
- SAVES SPACE – It can reduce the number of content items in your AGOL portal. For example, 5 web applications to show 5 web different maps, can now be 1 web application used to show 5 web maps, therefore reducing storage space and saving valuable service credits).
- SIMPLICITY – It’s very easy to implement.
- SAVES TIME – Creating one application is a lot faster than creating multiple applications for each web map you want to display. Additionally, if changes are made, they only need to be made to one application. Each time you want to reference another map, changing the web map in Web AppBuilder takes time to launch, choose a map and save. This URL scheme method takes seconds to implement.
- IMPORTED PROPERTIES – The properties of the web map you are referencing should carry through to the Web AppBuilder application (i.e. popups, symbology, layers).
So next time you’re working with a web application, just remember that the humble URL you are seeing can be quite powerful. You may be interested to know how the web application URL may be manipulated further, to quickly and easily modify other application characteristics.
Read more about what is possible via the following links :
Read more about configuring widgets with your URL Scheme web application:
Read more on predefining your app coordinates before launch