Skip to content

Commit

Permalink
Fix GeoJSON.initialize when no data
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jmvivo committed Nov 10, 2014
1 parent 4e445dd commit 04cdbc3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/proj4leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@
initialize: function(geojson, options) {
this._callLevel = 0;
L.GeoJSON.prototype.initialize.call(this, null, options);
this.addData(geojson);
if (geojson) {
this.addData(geojson);
}
},

addData: function(geojson) {
Expand Down

0 comments on commit 04cdbc3

Please sign in to comment.