Robert Scheitlin, GISP ,Ken Buja, Rene Rubalcava
If I am in a client browser session to a web mapping application, say http://gis.wpb.org/PublicWorksGridViewer/,
how would I print the webmap id to the console?
I was able to get it before, I just haven't remembered yet.
I've tried variations of the following, and nothing works as of yet:
console.log(webMap.itemId)
console.log(map.itemId)
console.log(map.itemInfo)
etc
Solved! Go to Solution.
Andres,
I am not an Admin in the "Enterprise GIS" GeoNet space that you have this question in. If you move this discussion to the Web AppBuilder for ArcGIS space where it really should be then I can convert this discussion to a Question.
For the AGOL application you can get the webmap in the console using:
this.config.webmap
For a WAB app running in Node.js you can use:
this.appConfig.map.itemId
For a deployed WAB Developer app use:
window._viewerMap.itemId
esri/arcgis/utils is a core JS API module that is used to create a map class out of a WebMap Id and has other methods.
Robert,
I went ahead and moved the discussion to theWeb AppBuilder for ArcGIS space, and I will mark your answer as correct when you convert it to a question.
This is great that you told me how to find the webmap ID, yet if I were to attempt to do this myself:
1
How would I find the webmap ID in a programmatic manner, like you did?
2
How would I search for a module in the app's code that was introduced via require (such as the esri/arcgis/utils module), in a programmatic manner to find out in which file of the application that module lives?
Why do you use 'this' for the AGOL and Node.js app, but 'window' for the deployed WAB app?
Andres,
1. How would I find the webmap ID in a programmatic manner, like you did?
A. If you are in a Widget.js or the MapManager.js then you would just use:
var mapId = this.map.itemId;
2. How would I search for a module in the app's code that was introduced via require (such as the esri/arcgis/utils module), in a programmatic manner to find out in which file of the application that module lives? I am not sure how to do that programatically...
Hi Robert, do you have a recommended approach I can take to find the webmap item id for any given configurable app/custom JS API app/etc?
I ask, because I see that none of these options work when trying to find the web map id in those cases:
this.config.webmap
this.appConfig.map.itemId
window._viewerMap.itemId
Andres,
No all those are specific to WAB. I am not aware of any global var that the JS API uses to store the webmap id.