// Create the map var map = new esri.Map("map", { extent:initExtent //initExtent is a variable w/ your initial extent }); // Set up and establish the data layers for the map, beginning with the basemap var primaryMapServiceURL = "http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"; var theBasemap = new esri.layers.ArcGISTiledMapServiceLayer(primaryMapServiceURL, { visible: false }); map.addLayer(theBasemap);
dojo.require("esri.map"); dojo.require("esri.layers.osm"); dojo.require("esri.layers.FeatureLayer"); dojo.require("dijit.dijit"); dojo.require("esri.dijit.Popup"); dojo.addOnLoad(init); var centerpoint = 0; var map = 0; var windowProxy; var current_open_marker = 0; var mouseover = 0; function init() { esriConfig.defaults.map.zoomDuration = 220; esriConfig.defaults.map.panDuration = 220; var popup = new esri.dijit.Popup(null, dojo.create("div")); map = new esri.Map("map", { infoWindow: popup, zoom: 6 }); var testlayer = initlayer('http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer', 'CTGF5889DE7840DB7AC4', 1); dojo.connect(map, "onLoad", function () { //var testlayer = initlayer('http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer', 'CTGF5889DE7840DB7AC4', 1); testlayer.show(); //map.hideZoomSlider(); $(document).ready(function () { //do future onload code }); }); } function initlayer(url, id, opacity) { var layer = new esri.layers.ArcGISTiledMapServiceLayer(url, { 'id': id, 'opacity': opacity, 'visible': false }); map.addLayer(layer); return layer; }
Yes, you can remove the basemap once it's added to the map. I was unable to find any resources in the documentation, but after some trial and error was able to do so by calling:
map._removeBasemap();
Which is extremely useful if you are using your own custom basemaps with Esri's basemaps. 🙂