'Geojson with multipolygons located in Italy projecting in the Red Sea
I am trying to project my geometries, composed of multipolygons, in my openlayers map. When I do this my geometries are displayed in the Red Sea near Yemen. I have seen that it looks like the coodinates are inverted (lat and long inverted). I get my geometries from a geoJson and I don´t know how to solve this. This is my code:
var myview = new View({
center: [15.450187402143, 41.18702782291],
projection: 'EPSG:4326',
zoom: 6
})
var mylayer = new TileLayer({
source: new OSM()
})
var layer = [mylayer]
const map = new Map({
target: 'map',
layers: layer,
view: myview
});
const vectorSource = new VectorSource({
format: new ol.format.GeoJSON(),
features: (new ol.format.GeoJSON()).readFeatures(geoJson, {dataProjection: 'EPSG:3857',
featureProjection: map.getView().getProjection()})
//EPSG:32633 - WGS 84 / UTM zone 33N
//features: new GeoJSON().readFeatures(geoJson, {dataProjection: 'EPSG:4326', FeatureProjection: map.getView().getProjection()})
});
vectorSource.addFeatures((vectorSource.getFormat()).readFeatures(geoJson));
const vectorLayer = new VectorLayer({
source: vectorSource
});
map.addLayer(vectorLayer);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
