1

Looked over the example can NOT figure out how to set basemap MANUALLY. I don't want a dijit widget, or any other libraries or anything like that. Just want to manually set a basemap to any of the already available types like Topographic, Satellites, Streets, etc. My script code so far is like this.

The part I can't figure out is marked with question marks.

 require([
 "esri/basemaps",
 "esri/map",
 "dojo/domReady!"
 ], function (esriBasemaps, Map) {
 /* ------------------------------------- */
 /* Basemap add one of the existing maps. */
 /* ------------------------------------- */
 esriBasemaps.myBasemap = {
 baseMapLayers ???
 };
 var map = new Map("map", {
 basemap: "myBasemap",
 center: [-118, 34.5],
 zoom: 8
 });
});
PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked May 8, 2015 at 23:16
2
  • why not just add the layer to the map? gis.stackexchange.com/questions/54509/… Commented May 12, 2015 at 21:27
  • @JohnGravois declaring as a basemap have some advantages at some use cases. Commented Oct 27, 2017 at 2:20

2 Answers 2

2

From the documentation javascript api:

basemap Optional Specify a basemap for the map. The following are valid options: "streets" , "satellite" , "hybrid", "topo", "gray", "dark-gray", "oceans", "national-geographic", "terrain" and "osm". Property added at v3.3. The "terrain" and "dark-gray" options added at v3.12.

You only need to put in the code the name of the basemap:
var map = new Map("map", {
basemap: "streets|satellite|hybrid|etc..",
center: [-118, 34.5],
zoom: 8
});

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
answered May 11, 2015 at 11:54
2
  • Your questions was completely useless re-read what I said it is marked in bold! Commented May 11, 2015 at 22:36
  • To use the default maps is not necessary to use esriBasemaps. esriBasemaps is used when you want to add a "custom" basemap and call it with the name (see: developers.arcgis.com/javascript/jsapi/esri.basemaps-amd.html ).To set the basemap, simply invoke the method map.setBasemap with the name of the desired basemap. Commented May 12, 2015 at 8:36
0

baseMapLayers parameter accepts array of wrapped urls like following:

esriBasemaps.myBasemap = {
 baseMapLayers: [
 {url: "https://services.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer"}
 ]
};

Official documentation: https://developers.arcgis.com/javascript/3/jsapi/esri.basemaps-amd.html Full source code sandbox: https://codepen.io/digz6666/pen/wPwPbW

answered Oct 27, 2017 at 2:19

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.