1

I have two GeoJSON files, the data should be Cartesian already. One GeoJSON (https://jsonblob.com/a4e3c8c9-0970-11ea-98b2-a57dd05dc415) file works fine but the polygons from the second one (https://jsonblob.com/d0ada7b7-0970-11ea-98b2-afb1520d8a49) don't show up and I don't get why.

OpenLayers do not throw any errors at all so it's difficult for me to find out the issue. Btw. I don't need any map tiles etc. I just want to see my polygon map. I can see all polygons in application like QGIS or mapsharper.org.

Here is a little bit code:

var vectorSource = new ol.source.Vector({
    features: (new ol.format.GeoJSON).readFeatures(geoJsonFeatures)
});

var vectorLayer = new ol.layer.Vector({
    source: vectorSource,
    style: stylePoligon
});

map = new ol.Map({
    //renderer: (['webgl', 'canvas']),
    target: 'map',
    layers: [
        vectorLayer
    ],
    view: new ol.View({
        //zoom: 14
    }),
    interactions: interactions,
    controls: ol.control.defaults({
        attribution: false,
        zoom: false,
    })
});

map.getView().fit(vectorSource.getExtent(), map.getSize());
2
  • 2
    By default an Openlayers 6 view is constrained to the extent of one EPSG:3857 world. The coordinates of the second GeoJSON exceed those limits. To remove the constraint define the view using new ol.View({multiWorld: true})
    – Mike
    Commented Nov 17, 2019 at 21:55
  • Big thanks, that solved the problem
    – BR75
    Commented Nov 18, 2019 at 14:08

0

Browse other questions tagged or ask your own question.