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
});
});
-
why not just add the layer to the map? gis.stackexchange.com/questions/54509/…john gravois– john gravois2015年05月12日 21:27:45 +00:00Commented May 12, 2015 at 21:27
-
@JohnGravois declaring as a basemap have some advantages at some use cases.digz6666– digz66662017年10月27日 02:20:41 +00:00Commented Oct 27, 2017 at 2:20
2 Answers 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
});
-
Your questions was completely useless re-read what I said it is marked in bold!Mike R.– Mike R.2015年05月11日 22:36:37 +00:00Commented 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.lele3p– lele3p2015年05月12日 08:36:50 +00:00Commented May 12, 2015 at 8:36
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