When I import the vector it simply does not show in the map. I tried with a raster and it worked fine. I tried now with both KML and GeoJSON and the same thing happen, I can see that it loaded in the Chrome Dev Tool and I can also see the data from there, but not in the map. I using the Vector Layer and the Image Vector Layer as a base.
The projection is EPSG:31982, UTM 22 S - Sirgas 2000
I'm using OpenLayers v5.3
I tried some things that I found in examples online, but none seems to work. Other questions related that did not helped me:
- Vector layer not displaying in OpenLayers
- OpenLayers does not display vector tiles in their origin projection
- https://stackoverflow.com/questions/28688466/vector-layer-is-not-showing-in-openlayers-3
- https://stackoverflow.com/questions/49769770/openlayers-4-wont-display-vector-layer
- https://stackoverflow.com/questions/18124081/openlayers-vector-layer-not-showing-on-the-whole-screen
- https://stackoverflow.com/questions/31879232/features-added-to-vector-layer-are-not-visible
- https://stackoverflow.com/questions/13491164/openlayers-vector-features-layer-invisible-do-not-render
- OpenLayers 4 does not display vector layer from geoJSON
- Layer does not displaying
- Not displaying any layers in OpenLayers
- Openlayers 3 Circle Vectors Not Visible
- https://stackoverflow.com/questions/49769770/openlayers-4-wont-display-vector-layer
Sample code I'm using:
proj4.defs('EPSG:31982', '+proj=utm +zone=22 +south +ellps=GRS80 +units=m +no_defs');
register(proj4);
var map = new Map({
layers: [
new TileLayer({
source: new OSM()
}),
new VectorLayer({
renderMode: 'image',
source: new VectorSource({
url: 'img/estradas.geojson',
format: new GeoJSON(),
projection: 'EPSG:31982'
}),
style: function(feature) {
style.getText().setText(feature.get('name'));
return style;
}
})
],
target: 'map',
view: new View({
center: transform(getCenter(imageExtent), 'EPSG:31982', 'EPSG:3857'),
zoom: 13
})
});
projection
isn't a valid option forVectorSource
. If you geojson contains EPSG:31982 coordinates you should replaceformat: new GeoJSON(), projection: 'EPSG:31982'
withformat: new GeoJSON({dataProjection: 'EPSG:31982'})