我正在从geoserver导入深水层(坐标系32632)的层,以使用OpenLayers进行显示,但我找不到它。 这是书面代码:
var urlgeoserver="http://localhost:8082/geoserver/BV_chiba/wms"
var urlcouches="BV_chiba:deepwatertable"
var deepwatertable = new ol.layer.Tile({
source:new ol.imageWMS({
url: urlgeoserver,
params:{"LAYERS": urlcouches, "TILED":"true"},
}),
title: "deepwatertable"
});
deepwatertable.setVisible(true);
var listcouches= [deepwatertable];
var map = new ol.map({
target: 'map',
layers:listcouches,
view: new ol.view({
center: ol.proj.transform([0, 0], 'EPSG:4326', 'EPSG:32632'),
zoom:10
})
});
答案 0 :(得分:1)
没有理由不能对WMS进行切片,因为可以缓存切片,所以效率更高,但是ol.layer.Tile
需要与ol.source.TileWMS
一起使用。如果您不希望平铺WMS,则必须将ol.layer.Image
与ol.source.ImageWMS
ol.Map
和ol.View
一起使用,也需要使用大写字母。投影(除非是EPSG:3857)必须在source和view选项中指定,并且必须在proj4定义中指定(如果使用OpenLayers 5,则必须注册),并且您将需要包括proj4库<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4.js"></script>
>
proj4.defs("EPSG:32632","+proj=utm +zone=32 +datum=WGS84 +units=m +no_defs");
ol.proj.proj4.register(proj4); // only needed if using OpenLayers 5
var urlgeoserver="http://localhost:8082/geoserver/BV_chiba/wms"
var urlcouches="BV_chiba:deepwatertable"
var deepwatertable = new ol.layer.Tile({
source:new ol.source.TileWMS({
url: urlgeoserver,
params:{"LAYERS": urlcouches, "TILED":"true"},
projection: 'EPSG:32632'
}),
title: "deepwatertable"
});
deepwatertable.setVisible(true);
var listcouches= [deepwatertable];
var map = new ol.Map({
target: 'map',
layers:listcouches,
view: new ol.View({
center: ol.proj.transform([0, 0], 'EPSG:4326', 'EPSG:32632'),
zoom:10,
projection: 'EPSG:32632'
})
});