我试着使用openlayer来显示geoserver tif,但是它显示的不正确。以下是我的步骤:
const tifMap = (target) => {
new Map({
target,
pixelRatio: 1,
layers: [
new TileLayer({
source: new TileWMS({
url: 'http://localhost:8080/geoserver/topp/wms',
params: {'LAYERS': 'topp:states',
'BBOX': '-124.73142200000001,24.955967,-66.969849,49.371735',
'CRS': 'EPSG:4326',
'FORMAT': 'image/jpeg',
'VERSION': '1.1.0'
},
serverType: 'geoserver'
})
})
],
view: new View({
center: [741189, -3741196],
zoom: 4
})
})
};
发布于 2019-03-08 13:41:01
OpenLayers根据源选项中的投影集和用于TileWMS或ImageWMS的视图网格自动创建BBOX和CRS参数。最大范围可以设置在倾斜(在服务器投影单元)或在层(在视图投影单元)。假设服务器只支持EPSG:4326,并且希望以EPSG:3857的形式显示平铺输出,那么这两种方式都可以:
new TileLayer({
source: new TileWMS({
url: 'http://localhost:8080/geoserver/topp/wms',
params: {'LAYERS': 'topp:states',
'FORMAT': 'image/jpeg',
'VERSION': '1.1.0'
},
serverType: 'geoserver',
projection: 'EPSG:4326'
}),
extent: transformExtent([-124.73142200000001,24.955967,-66.969849,49.371735], 'EPSG:4326', 'EPSG:3857')
})。
new TileLayer({
source: new TileWMS({
url: 'http://localhost:8080/geoserver/topp/wms',
params: {'LAYERS': 'topp:states',
'FORMAT': 'image/jpeg',
'VERSION': '1.1.0'
},
serverType: 'geoserver',
projection: 'EPSG:4326',
tilegrid: createXYZ({extent: [-124.73142200000001,24.955967,-66.969849,49.371735]})
})
})https://stackoverflow.com/questions/55060494
复制相似问题