OpenLayers3 GeoJSON with CRS throws error

717 Views Asked by At

I have a geoJSON resource as follows:

{
"type": "FeatureCollection",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [...]
}

When I try to create the layer using:

var myLayer = new ol.layer.Vector( { 
    source: new ol.source.Vector( {
        url: "http://some.closed.api/resource.json",
        format: new ol.format.GeoJSON(),
        strategy: ol.loadingstrategy.bbox
    } )
} );

I get the following error and the GeoJSON isn't loaded into the map:

Uncaught AssertionError: Assertion failed: transform should be defined

I downloaded the file locally and put on my web server and remove the "crs" or replace it with "EPSG:4326" it works as expected.

Can someone suggest a solution that doesn't require hardcoding a CRS into my olSource constructor?

0

There are 0 best solutions below