用arcgis api for javascript写加载天地图的完整页面代码
时间: 2023-03-14 09:21:58 浏览: 206
可以参考以下示例代码实现加载天地图的完整页面: <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>ArcGIS API for JavaScript 示例</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.16/esri/themes/light/main.css">
<script src="https://js.arcgis.com/4.16/"></script>
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script>
require([
"esri/Map",
"esri/views/MapView",
"esri/layers/WebTileLayer"
], function (Map, MapView, WebTileLayer) {
// 创建天地图WebTileLayer
let tdLayer = new WebTileLayer({
urlTemplate: "http://t0.tianditu.gov.cn/vec_w/wmts?service=wmts&request=GetTile&version=1.0.0&LAYER=vec&tileMatrixSet=w&TileMatrix={level}&TileRow={row}&TileCol={col}&style=default&format=tiles",
subDomains: ["t0"]
}); // 将图层添加到地图
let map = new Map({
basemap: {
baseLayers: [tdLayer]
}
}); // 创建地图视图
let view = new MapView({
container: "viewDiv",
map: map,
center: [116.46, 39.92],
zoom: 6
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>
阅读全文