ol.source.XYZ支援的ArcGIS REST tile服務具有定制的tile大小和投影

ArcGIS REST with 512x512 Tiles
ol/source/XYZ支援的ArcGIS REST tile服務具有定制的tile大小(這裡:512x512像素)和投影(這裡:EPSG:4326)。
<!DOCTYPE html>
<html lang="zn">
<head>
<meta charset="UTF-8">
<!-- 引入OpenLayers CSS樣式 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.13.0/css/ol.css"
type="text/css">
<!-- 引入OpenLayers JS庫 -->
<script src="https://cdn.jsdelivr.net/gh/openlayers/openlayers.github.io@master/en/v6.13.0/build/ol.js"></script>
<!-- css代碼 -->
<style type="text/css">
.map {
width: 100%;
height: 600px;
}
</style>
</style>
<title>ArcGIS REST with 512x512 Tiles</title>
</head>
<body>
<div id="map" class="map"></div>
</body>
<script>
// 初始化地圖
const map = new ol.Map({
// 綁定doc元素
target: 'map',
layers: [
// 添加圖層
new ol.layer.Tile({
// https://openlayers.org/en/latest/apidoc/module-ol_source_XYZ-XYZ.html
source: new ol.source.XYZ({
attributions: 'Copyright:© 2013 ESRI, i-cubed, GeoEye',
url:
'https://services.arcgisonline.com/arcgis/rest/services/' +
'ESRI_Imagery_World_2D/MapServer/tile/{z}/{y}/{x}',
maxZoom: 15, // 最大級别
projection: 'EPSG:4326', // 投影坐标
tileSize: 512, // 瓦片大小
maxResolution: 180 / 512, // 最大分辨率
wrapX: true, // 是否水準包裹世界
}),
}),
],
// 視圖範圍
view: new ol.View({
center: [0, 0], // 視圖的初始中心。projection如果未設定使用者投影,則使用該選項指定中心的坐标系。如果未設定,則不會擷取層源,但稍後可以使用 設定中心#setCenter。
projection: 'EPSG:4326', // 投影。預設值為球形墨卡托'EPSG:3857'
zoom: 2, // 僅在resolution未定義時使用。用于計算視圖初始分辨率的縮放級别。
minZoom: 2, // 預設0。用于确定分辨率限制的最小縮放級别。它與maxZoom(or minResolution) 和一起使用zoomFactor。請注意,如果maxResolution還提供了,它的優先級高于minZoom.
}),
});
</script>
</html>