Add a mapservice as a basemap?

3058
16
08-18-2017 01:15 AM
Muqit_Zoarder
Occasional Contributor

Hello Everyone, is it possible to add a featureclass mapservice as a base map in esri basemap gallery with existing basemaps in arcgis js api and also can I see the pop-up information of layer onclick event?

Thanks

Tags (1)
0 Kudos
16 Replies
Muqit_Zoarder
Occasional Contributor

Hi, thanks i can see ur map now, can you please test my mapservice here i have included?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Muqit,

   Your layer is in a different spatial reference then the standard esri basemaps so it will not work with them. 

Muqit_Zoarder
Occasional Contributor

Hello Robet, can I change spatial ref on the fly?

Regards

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

No all your basemaps have the be the same spatial reference to begin with.

BrandonPrice
Occasional Contributor

To piggy back on this, is it possible to add an onclick event to a basemap toggle? such as to remove another layer in the map as well as the basemap change?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Brandon,

   Sure just add your logic to the selection-change event handler:

      basemapGallery.on("selection-change", function(evt) {
        if(evt.target._selectedBasemap.title === "Community Addresses"){
          var lyr = map.getLayer(map.layerIds[0]);
          if(lyr && !lyr.infoTemplates){
            lyr.setInfoTemplates({
              0: { infoTemplate: _addressInfoTemplate }
            });
          }
        }
        var pane = registry.byId("bmTitlePane");
        if (pane.open) {
          pane.toggle();
        }
      });
BrandonPrice
Occasional Contributor

Thanks Robert. This was very helpful. I am still trying to work this out.

0 Kudos