kartena / Proj4Leaflet

Smooth Proj4js integration with Leaflet.
http://kartena.github.io/Proj4Leaflet/
BSD 2-Clause "Simplified" License
589 stars 173 forks source link

Fix GeoJSON.initialize when no data #77

Closed jmvivo closed 9 years ago

jmvivo commented 9 years ago

When you try to create a L.Proj.GeoJSON layer with no data (to add it after layer creation):

    var layer = L.Proj.geoJson();
    layer.addData(geojson).addTo(map);

You get an exception:

    Uncaught TypeError: Cannot read property 'features' of undefined
edrex commented 9 years ago

I hit this problem right off, and this pull request fixes it.

It's pretty common to create a GeoJSON layer synchronously and then add the data later, so this bug is critical for GeoJSON support.

The code change looks fine.

:+1:

pthorin commented 9 years ago

Thanks!