Tiled WMS Wrapping
Tiled WMS Wrapping示例。 WMS 瓦片 dateline wrap 180
默认情况下,WMS 瓦片会在 180° 经线处复用。通过将 wrapX 选项设置为 false 可以禁用此行为。
main.js
js
import Map from 'ol/Map.js';
import View from 'ol/View.js';
import TileLayer from 'ol/layer/Tile.js';
import OSM from 'ol/source/OSM.js';
import TileWMS from 'ol/source/TileWMS.js';
const layers = [
new TileLayer({
source: new OSM(),
}),
new TileLayer({
source: new TileWMS({
url: 'https://ahocevar.com/geoserver/ne/wms',
params: {'LAYERS': 'ne:ne_10m_admin_0_countries', 'TILED': true},
serverType: 'geoserver',
}),
}),
];
const map = new Map({
layers: layers,
target: 'map',
view: new View({
center: [0, 0],
zoom: 1,
}),
});index.html
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>瓦片式 WMS 跨越 180° 经线</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": "wms-tiled-wrap-180",
"dependencies": {
"ol": "10.11.0"
},
"devDependencies": {
"vite": "^8.1.5"
},
"scripts": {
"start": "vite",
"build": "vite build"
}
}