使用 OpenLayers 不显示从地理服务器导入的图层
Layer imported from geoserver is not displayed using OpenLayers
我正在从地理服务器导入 deepwatertable 层(坐标系 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
})
});
WMS没有理由不能分块,分块可以缓存更高效,但是ol.layer.Tile
需要和ol.source.TileWMS
一起使用。如果您不想要平铺 WMS,则必须使用 ol.layer.Image
和 ol.source.ImageWMS
ol.Map
,并且 ol.View
也需要大写字母。投影(除非它是 EPSG:3857)必须在源和视图选项中指定,并在 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'
})
});
我正在从地理服务器导入 deepwatertable 层(坐标系 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
})
});
WMS没有理由不能分块,分块可以缓存更高效,但是ol.layer.Tile
需要和ol.source.TileWMS
一起使用。如果您不想要平铺 WMS,则必须使用 ol.layer.Image
和 ol.source.ImageWMS
ol.Map
,并且 ol.View
也需要大写字母。投影(除非它是 EPSG:3857)必须在源和视图选项中指定,并在 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'
})
});