diff --git a/leaflet-core.html b/leaflet-core.html
index 1785909..0afcfaf 100644
--- a/leaflet-core.html
+++ b/leaflet-core.html
@@ -723,7 +723,8 @@
},
detached: function() {
- this._mutationObserver.disconnect();
+ if(this._mutationObserver)
+ this._mutationObserver.disconnect();
},
_viewChanged: function(newValue, oldValue) {
diff --git a/leaflet-geojson.html b/leaflet-geojson.html
index b9607c6..3785f7f 100644
--- a/leaflet-geojson.html
+++ b/leaflet-geojson.html
@@ -149,6 +149,16 @@
lineJoin: {
type: String,
value: null
+ },
+ /**
+ * The attribute `options` sets the options that are passed additonally when the geoJson-Object is created.
+ * (See http://leafletjs.com/reference.html#geojson)
+ * @attribute options
+ * @type Object
+ */
+ options : {
+ type : Object,
+ value : null
}
},
@@ -164,8 +174,7 @@
if (this.feature) {
this.container.removeLayer(this.feature);
}
- this.feature = L.geoJson(this.data);
-
+ this.feature = L.geoJson(this.data, this.options);
this.feature.addTo(this.container)
.setStyle({
color: this.color,
diff --git a/leaflet-layer-group.html b/leaflet-layer-group.html
index 98d8b5f..d81e602 100644
--- a/leaflet-layer-group.html
+++ b/leaflet-layer-group.html
@@ -5,9 +5,9 @@
##### Example
-
-
-
+
+
+
@element leaflet-layer-group
@@ -17,7 +17,7 @@
-->
-
+
@@ -31,33 +31,45 @@
container: {
type: Object,
observer: '_containerChanged'
- }
+ },
+ fitMapToBounds : {
+ type: Boolean,
+ value: false
+ }
},
-
- ready: function() {
+ resetMutationObserver : function() {
this._mutationObserver = new MutationObserver(this.registerContainerOnChildren.bind(this));
this._mutationObserver.observe(this, {childList: true});
},
_containerChanged: function() {
if (this.container) {
- var feature = L.layerGroup()
+ var feature = L.layerGroup();
this.feature = feature;
this.feature.addTo(this.container);
- this.registerContaierOnChildren();
+ this.registerContainerOnChildren();
}
},
- registerContaierOnChildren: function() {
+ registerContainerOnChildren: function() {
+ this.resetMutationObserver();
for (var i = 0; i < this.children.length; i++) {
this.children[i].container = this.feature;
}
+ if(this.fitMapToBounds && this.container && this.feature) {
+ var layers = this.feature.getLayers();
+ if (layers.length > 0)
+ this.container.fitBounds(L.featureGroup(layers).getBounds());
+ }
+
+
},
detached: function() {
if (this.container && this.feature) {
this.container.removeLayer(this.feature);
}
+ if(this._mutationObserver)
this._mutationObserver.disconnect();
}
});