desktop - Manually setting basemap using ArcGIS API for JavaScript? -
looked on example can not figure out how set basemap manually. don't want dijit widget, or other libraries or that. want manually set basemap of available types topographic, satellites, streets, etc.
following api reference:
the part can't figure out marked question marks. if me out, appreciate it.
require([ "esri/basemaps", "esri/map", "dojo/domready!" ], function (esribasemaps, map) { /* ------------------------------------- */ /* basemap add 1 of existing maps. */ /* ------------------------------------- */ esribasemaps.mybasemap = { basemaplayers ??? }; var map = new map("map", { basemap: "mybasemap", center: [-118, 34.5], zoom: 8 });
});
the code in esri/basemaps documentation works fine, combined create map sample.
here's part wondered about:
esribasemaps.mybasemap = { basemaplayers: [ { url: "http://services.arcgisonline.com/arcgis/rest/services/specialty/delorme_world_base_map/mapserver" } ], title: "my basemap" };
here's full example. copy , paste following arcgis api javascript sandbox see how works.
<!doctype html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no"/> <title>simple map</title> <link rel="stylesheet" href="http://js.arcgis.com/3.13/esri/css/esri.css"> <style> html, body, #map { height: 100%; width: 100%; margin: 0; padding: 0; } body { background-color: #fff; overflow: hidden; font-family: "trebuchet ms"; } </style> <script src="http://js.arcgis.com/3.13/"></script> <script> var map; require(["esri/basemaps", "esri/map", "dojo/domready!"], function(esribasemaps, map) { esribasemaps.mybasemap = { basemaplayers: [ { url: "http://services.arcgisonline.com/arcgis/rest/services/specialty/delorme_world_base_map/mapserver" } ], title: "my basemap" }; map = new map("map", { basemap: "mybasemap", center: [-122.45, 37.75], // longitude, latitude zoom: 13 }); }); </script> </head> <body> <div id="map"></div> </body> </html>
Comments
Post a Comment