From 04cdbc3387e7c787c391e9c1e53b75e1fb59459c Mon Sep 17 00:00:00 2001 From: jmvivo Date: Mon, 10 Nov 2014 16:20:37 +0100 Subject: [PATCH] Fix GeoJSON.initialize when no data 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 --- src/proj4leaflet.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/proj4leaflet.js b/src/proj4leaflet.js index ecdea63..cb59202 100644 --- a/src/proj4leaflet.js +++ b/src/proj4leaflet.js @@ -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) {