1

I am using the following coming back from a socketio connection:

L.geoJson(data.streets, {
     onEachFeature: map.onEachFeature
});

It's throwing the following error:

Invalid GeoJSON object.

My GeoJSON is here

I've run it through several JSON/GeoJSON validating tools and they all come back as valid. It's also definitely already a json object (I tried with JSON.parse(data.streets))

What am I missing? I did use a flatProperties option on my osmtogeojson library but as mentioned, the above code validates on all the online checks I can find.

  • As @FranceImage showed, the GeoJSON itself is valid. So it must be how you are using it. Can you post a jsfiddle showing the problem? – Josh Oct 22 '14 at 15:24
1

The GeoJson you link to is valid

See by yourself http://jsfiddle.net/FranceImage/pcqsne4z/

L.geoJson(getData(), {
    onEachFeature: handleFeature
    }
).addTo(map);

function getData() { 
return {
    "type": "FeatureCollection",
...
...
        "geometry": {
            "type": "LineString",
            "coordinates": [
                [-1.0950612, 50.7902086],
                [-1.0953699, 50.790231]
            ]
        }
    }]};
}

You have to check what is in data.streets

  • Honestly I'm not sure what changed by my browser stopped throwing that error today, so I'll mark this as answered. So strange and sorry for wasting your time :/ – Titan Oct 23 '14 at 9:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.