Coverage [minx,miny,maxx,maxy] is [12, 4, 13, 6, 3], index [x,y,z] is [2, 5, 3]错误原因及其解决方式
加载矢量切片的时候会出现上述错误,为什么会出现上述错误呢?以前我也遇到过,今天有个人问我就在这写一下供他人参考。主要的原因是map中设置的坐标系和请求url中坐标系不一致。
Openlayers解决方案
var map = new ol.Map({
layers: [osm, vectorTile],
target: 'map',
view: new ol.View({
center: [116.46, 39.92],
maxZoom: 22,
zoom: 3,
projection: 'EPSG:4326'
})
});
tileUrlFunction: function (tileCoord) {
return 'http://localhost:8080/geoserver/gwc/service/tms/1.0.0/' + layerName + '@EPSG%3A4326@pbf/' + (tileCoord[0] - 1)
+ '/' + tileCoord[1] + '/' + (Math.pow(2, tileCoord[0] - 1) + tileCoord[2]) + '.pbf';
}
两者坐标系都是4326
LeaFlet解决方案:
var latlng = L.latLng(39.92, 116.46);
var map = L.map('map', {
center: latlng,
zoom: 3,
maxZoom: 22,
crs: L.CRS.EPSG4326
})
var url = "http://localhost:8080/geoserver/gwc/service/tms/1.0.0/cite:university@EPSG:4326@pbf/{z}/{x}/{y}.pbf";
两者都是4326,注意无论Openlayers还是Leaflet默认坐标系都是3857
转载自:https://blog.csdn.net/weixin_40184249/article/details/86318452