[GIS] How to change the default basemap in a Web AppBuilder app via code

arcgis-web-appbuilderbasemap

I created an app in the Web AppBuilder v2.0, running at http://my-PC:3344/webappbuilder, and included the standard BaseMap Widget.

I downloaded the resulting app and deployed it using IIS at C:\inetpub\wwwroot\MyApp. I've subsequently made some changes by editing the JS files directly in an IDE (not via the Web AppBuilder UI) and it's all working fine.

Now I'd like to change the default basemap which is shown when the app opens.

  • \MyApp\config.json lists the BaseMapGallery widget
  • \MyApp\configs\BasemapGallery\config_BaseMap Gallery.json lists the
    available basemaps
  • neither file seems to configure the default basemap

Which files should I edit to change the default basemap?

Edit: I am using the LocalLayer widget to specify the map layers manually

Best Answer

Preparation: (1) change basemap of your AGOL map, or (2) make several AGOL maps with different basemaps. The latter is more work and it might be more money if you pay for data stored in them, but it's more elegant.

I didn't test the first case, it might take some time until the new basemap gets applied, but if you need to change the basemap just once in a longer time, it should be OK. Forbiding your browser's caching should make it faster.

In the latter case you have two options: you can just add itemid={mapIDfrom AGOL} into the querystring and reload. This should be OK in most cases. Or, if you incorporate your WAB into some other app (as I do), you might make dynamic the map.itemInfo property in Jimu.js/mapManager.js, line 318 or something like this.