自己服务器发电子地图切片服务,设置wrapX:true时也不能重复显示问题解决
不能重复显示:
代码如下:
//切片调用
var world_tms = new ol.layer.Tile({
name:"切片",
visible: true,
source: new ol.source.XYZ({
matrixSet:"EPSG:4326",
projection: "EPSG:4326",
tileGrid: tilegrid,
url: 'http://localhost/geoserver/gwc/service/tms/1.0.0/world@EPSG:4326@png/{z}/{x}/{-y}.png',
crossOrigin:"anonymous", //跨域设置
wrapX:true
})
});
自定义投影后,能重复显示
代码如下:
//自定义投影
var projectionTile = new ol.proj.Projection({
code: 'EPSG:4326',
units: 'degrees',
axisOrientation: 'neu',
global:true
});
//切片调用
var world_tms = new ol.layer.Tile({
name:"切片",
visible: true,
source: new ol.source.XYZ({
matrixSet:"EPSG:4326",
projection: projectionTile,
tileGrid: tilegrid,
url: 'http://localhost/geoserver/gwc/service/tms/1.0.0/world@EPSG:4326@png/{z}/{x}/{-y}.png',
crossOrigin:"anonymous", //跨域设置
wrapX:true
})
});