Select to view content in your preferred language

Print webmap id to the console from a client browser session to a web mapping application

2113
14
Jump to solution
05-31-2019 08:36 AM
AndresCastillo
MVP Regular Contributor

 Robert Scheitlin, GISP Champion,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

0 Kudos
14 Replies
RobertScheitlin__GISP
MVP Emeritus

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.

AndresCastillo
MVP Regular Contributor

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?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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... 

0 Kudos
AndresCastillo
MVP Regular Contributor

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
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

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.

0 Kudos