<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ChangetheBasemap</title>
<style>
html,
body,
#mapDiv {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
}
</style>
<link rel="stylesheet" href="https://js.arcgis.com/4.20/esri/themes/light/main.css">
<script src="https://js.arcgis.com/4.20/"></script>
<script>
require([
"esri/config",
"esri/Map",
"esri/views/MapView",
"esri/widgets/BasemapToggle"
], function(esriConfig, Map, MapView, BasemapToggle) {
esriConfig.apiKey = "YOUR-KEY";
//创建地图
const map = new Map({
basemap: "arcgis-topographic"
});
//创建地图视图
const view = new MapView({
container: "mapDiv",
map: map,
center: [-118.805, 34.027],
zoom: 13
});
//创建新底图
const basemapToggle = new BasemapToggle({
view: view,
nextBasemap: "arcgis-imagery"
});
//设置小部件存在位置
view.ui.add(basemapToggle, "bottom-right");
})
</script>
</head>
<body>
<d id="mapDiv"></d>
</body>
</html>
WEBGIS切换地图底图BasemapToggle(在底图之间切换)
最新推荐文章于 2022-05-23 16:45:30 发布