I have two layers in my OpenLayers map, the background in WMS and GeoJSON features in a vector layer, both in ESPG:3006. (And a standard OpenStreetMap background just to see which one of the layers that shows correct).
The problem is that the default projection is ESPG:4326, and if I specify the projection in the view of the map-object to ESPG:3006, the vector layer is correct but the WMS doesn't appear at all. To see the WMS layer, the projection needs to be specified for the WMS layer and the map will automatically be in correct projection, but then the vector layer appears in wrong position at the map.
What can I do to get both layers in correct projection and position?
const standardmap = new ol.layer.Tile({
source: new ol.source.OSM()
});
const WMSmap = new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'xxxxxxx',
params: {
'LAYERS': '0',
'CRS': 'EPSG:3006',
'VERSION': '1.3.0',
'FORMAT': 'image/png'
}
})
});
const geoJsonFeatures = new ol.layer.Vector({
source: new ol.source.Vector({
features: (new ol.format.GeoJSON()).readFeatures(geojsonObject)
}),
style: styleFunction
});
let map = new ol.Map({
target: 'map',
layers: [standardmap, WMSmap, geoJsonFeatures],
view: new ol.View({
center: center,
zoom: 5
})
});
The small red figures should be somewhere in "Region Mi...", not in Netherlands.