how to change basemap for a url. I want this layer to become my basemap layer on button click.
like for topo button i want this layer to come as basemap. LINZ/geotiffs (MapServer)
How to change my code accordingly. Thanks in advance
var topoBtn =domConstruct.toDom("<div class='map-button esri-component esri-widget--button esri-widget topo mapbtncolor' role='button' title='topo'>TOPO<span aria-hidden='true' role='presentation'></span></div>") ;
var satelliteBtn = domConstruct.toDom("<div class='map-button esri-component esri-widget--button esri-widget sat basmapcolor' id='satt' role='button' title='sattelite'>SATELLITE<span aria-hidden='true' role='presentation'></span></div>") ;
function setbasemap(basemap){
webmap.basemap = basemap;
}
topoBtn.addEventListener('click', function(){
setbasemap('topo');
});
satelliteBtn.addEventListener('click', function(){
setbasemap('satellite');
});
Solved! Go to Solution.
Hi rajni sharma,
What do you think about this one?
ArcGIS JavaScript with New Zealand data - LINZ Basemapgallery
BR,
Egge-Jan
HI
I have created an online arcgis map with basemap as topographic and top layer is this LINZ/geotiffs (MapServer) I cannot able to use this layer directly as basemap in my app it disturb my functionality so i use topographic layer as basmap for this webmap ,
Furthermore, i have done this on click of button by dynamically changing portalItem id on click, but for this i have to refresh my page for toppo button.
var webmap = new WebMap({
portalItem: {
// autocasts as new PortalItem()
id: "<?=$map_id?>"
}
}); //End WebMap
Is their any other way, i can do it smoothly? Dynamically changing webmap, or any other way???
Hoping for positive response from the community.
Please don't send link of Basemap | ArcGIS API for JavaScript 4.15
I have already read it, but don't know how to practically implment it.
Have you looked at the sample for using a custom basemap?
https://developers.arcgis.com/javascript/latest/sample-code/sandbox/index.html?sample=basemap-custom
Hi rajni sharma,
What do you think about this one?
ArcGIS JavaScript with New Zealand data - LINZ Basemapgallery
BR,
Egge-Jan
// Basemaps Eagle Technology New Zealand
let LINZ_Topographic_Eagle_NZ = new Basemap({portalItem: {id: "<?=$map_id?>"}}); //NZ - LINZ Topographic
// Click event on Topo Button
topoBtn.addEventListener('click', function(){
setbasemap(LINZ_Topographic_Eagle_NZ);
});