[英]Manually setting basemap using ArcGIS API for JavaScript?
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. 我不需要dijit小部件或任何其他库或类似的东西。 Just want to manually set a basemap to any of the already available types like Topographic, Satellites, Streets, etc. 只想手动将底图设置为任何已经可用的类型,例如“地形”,“卫星”,“街道”等。
Following this API reference: 遵循此API参考:
Object: esri/basemaps 对象:esri /底图
The part I can't figure out is marked with question marks. 我不知道的部分标有问号。 If some could help me out, would really appreciate it. 如果有人可以帮助我,将不胜感激。
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
});
}); });
The code in the esri/basemaps documentation works fine, combined with the create a map sample . esri / basemaps文档中的代码可以很好地与创建地图示例结合使用。
Here's the part you wondered about: 这是您想知道的部分:
esriBasemaps.myBasemap = {
baseMapLayers: [
{
url: "http://services.arcgisonline.com/ArcGIS/rest/services/Specialty/DeLorme_World_Base_Map/MapServer"
}
],
title: "My Basemap"
};
Here's a full example. 这是一个完整的例子。 Copy and paste the following into the ArcGIS API for JavaScript Sandbox to see how it works. 将以下内容复制并粘贴到ArcGIS API for JavaScript沙箱中,以查看其工作方式。
<!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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.