AnsweredAssumed Answered

How to set ESRI Community map as basemap

Question asked by rhyck.m on Nov 22, 2019
Latest reply on Nov 25, 2019 by dcoley

All, I have been having a hard time with this and I thought I ask the community. ESRI recently updated the community map and I really like to use it as a basemap in my application. There is no name for it in the API like others ('streets', 'topo', etc) and of course I could not find the rest end point for the service. So I tried to make use of the BasemapGallery which includes the Community map and here is the script I tried:

 


// init the map
require([
    'esri/map',
    'esri/dijit/BasemapGallery',
    'dojo/_base/array'
], (MapBasemapGalleryarray=> {

    const __map = new Map("map-view", {
        center: [-84.24245840.144803],
        zoom: 15,
        basemap: "topo-vector" // there is no name for the community map in the collection
    });

    const _basemapGallery = new BasemapGallery({
        showArcGISBasemaps: true,
        map: __map
      }, "basemapGalleryDiv");
    _basemapGallery.on("load"evt => {
        console.log(evt.target.basemaps);
        array.map(evt.target.basemapsb =>{
            if(b.title === "Community Map"){
                _basemapGallery.select(b.id); // This only selects the map (will be added on top of the current basemap 'topo-vector') but not setting it as basemap
            }
        });
    });
});

 

 

Any suggestions please?

Outcomes