Stadia Maps (Stamen 瓦片 图层 Composition)
Stadia Maps (Stamen 瓦片 图层 Composition)示例。 stamen watercolor terrain-labels two-layers stadia-maps
两个图层组组合在一起:watercolor 底图图层叠加来自 Stamen 的地形标注图层。
main.js
js
import Map from 'ol/Map.js';
import View from 'ol/View.js';
import TileLayer from 'ol/layer/Tile.js';
import {fromLonLat} from 'ol/proj.js';
import StadiaMaps from 'ol/source/StadiaMaps.js';
const map = new Map({
layers: [
// 注意:来自 Stadia Maps 的图层在本地开发或大多数生产
// 网页部署中不需要 API 密钥。详情请参阅 https://docs.stadiamaps.com/authentication/。
new TileLayer({
source: new StadiaMaps({
layer: 'stamen_watercolor',
// apiKey: 'OPTIONAL'
}),
}),
new TileLayer({
source: new StadiaMaps({
layer: 'stamen_terrain_labels',
// apiKey: 'OPTIONAL'
}),
}),
],
target: 'map',
view: new View({
center: fromLonLat([-122.416667, 37.783333]),
zoom: 12,
}),
});index.html
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Stadia Maps(Stamen 瓦片图层组合)</title>
<link rel="stylesheet" href="node_modules/ol/ol.css">
<style>
.map {
width: 100%;
height: 400px;
}
</style>
</head>
<body>
<div id="map" class="map"></div>
<script type="module" src="main.js"></script>
</body>
</html>package.json
json
{
"name": "stamen",
"dependencies": {
"ol": "10.11.0"
},
"devDependencies": {
"vite": "^8.1.5"
},
"scripts": {
"start": "vite",
"build": "vite build"
}
}