[英]Layer imported from geoserver is not displayed using OpenLayers
I'm importing layer of deepwatertable (coordinate system 32632) from geoserver to display it using OpenLayers but i cannot find it.我正在从地理服务器导入深水表层(坐标系 32632)以使用 OpenLayers 显示它,但我找不到它。 Here is the written code:
这是编写的代码:
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
})
});
There's no reason why WMS cannot be tiled, it's more efficient as as tiles can be cached, but ol.layer.Tile
needs to be used with ol.source.TileWMS
.没有理由不能对 WMS 进行平铺,因为可以缓存平铺,因此效率更高,但
ol.layer.Tile
需要与ol.source.TileWMS
一起使用。 If you don't want tiled WMS you must use ol.layer.Image
with ol.source.ImageWMS
ol.Map
and ol.View
also need capital letters.如果你不想平铺 WMS,你必须使用
ol.layer.Image
和ol.source.ImageWMS
ol.Map
和ol.View
也需要大写字母。 The projection (unless it is EPSG:3857) must be specified in the source and view options, and in a proj4 definition (and registered if using OpenLayers 5), and you will need to include the proj4 library <script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4.js"></script>
投影(除非是 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'
})
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.