Access a map

Web AppBuilder for ArcGIS is a map-centric application. It provides a map property defined in the BaseWidget class to access the map. You can access the map property through this map. The widget’s map property is a type of esri.Map from ArcGIS JavaScript API, configured in the config.json file. You can access all map features provided by ArcGIS JavaScript API. Code the widget the same as writing a regular ArcGIS JavaScript application.

When a widget instantiates, the map passes into it. As a result, you can access a map property in the postCreate or startup methods.

Modify the UI template and add a div tag to display the map ID property:

<div>
    <div>${nls.label1}.</div>
    <div>${nls.label2}.[${config.configText}]</div>
      <div data-dojo-attach-point="mapIdNode"></div>
</div>

Add JavaScript code to access the map:

startup: function(){
  this.inherited(arguments);
  this.mapIdNode.innerHTML = 'map id:' + this.map.id;
}

For 3D widget, the map property is replaced by sceneView , use this.sceneView to access the scene in your widget.