1

I'm importing layer of deepwatertable (coordinate system 32632) from geoserver to display it using OpenLayers but i cannot find it. 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
})
});
Ian Turton
  • 10,018
  • 1
  • 28
  • 47

1 Answers1

1

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. 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. 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>

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'
  })
});
Mike
  • 16,042
  • 2
  • 14
  • 30