使用 ArcGIS API 为 JavaScript 手动设置底图?

Manually setting basemap using ArcGIS API for JavaScript?

查看示例无法弄清楚如何手动设置底图。我不想要 dijit 小部件,或任何其他库或类似的东西。只想手动将底图设置为任何已经可用的类型,如地形、卫星、街道等。

关注此 API 参考:

Object: esri/basemaps

不明白的部分用问号标出。如果有人能帮助我,将不胜感激。

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
});

});

代码在esri/basemaps documentation works fine, combined with the create a map sample.

这是你想知道的部分:

esriBasemaps.myBasemap = {
  baseMapLayers: [
    {
      url: "http://services.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer"
    }
  ],
  title: "My Basemap"
};

这是一个完整的例子。将以下内容复制并粘贴到 ArcGIS API for JavaScript Sandbox 中以查看其工作原理。

<!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>