|
@@ -32,12 +32,13 @@
|
32
|
32
|
|
33
|
33
|
updateLayers: function(url, geoData) {
|
34
|
34
|
if (geoData.type == 'FeatureCollection'){
|
35
|
|
- for (var i=0;i<geoData.features.length;i++) {
|
36
|
|
- var id = geoData.features[i].id;
|
37
|
|
- if (!this.features[id]) {
|
38
|
|
- this.layer.addData(geoData.features[i]);
|
39
|
|
- this.features[id] = true;
|
40
|
|
- }
|
|
35
|
+ geoData = geoData.features;
|
|
36
|
+ }
|
|
37
|
+ for (var i=0;i<geoData.length;i++) {
|
|
38
|
+ var id = geoData[i].id;
|
|
39
|
+ if (!this.features[id]) {
|
|
40
|
+ this.layer.addData(geoData[i]);
|
|
41
|
+ this.features[id] = true;
|
41
|
42
|
}
|
42
|
43
|
}
|
43
|
44
|
if (!this.cache[url]) {
|
|
@@ -49,9 +50,11 @@
|
49
|
50
|
L.GridLayer.prototype.onAdd.call(this, map);
|
50
|
51
|
map.addLayer(this.layer);
|
51
|
52
|
this.map = map;
|
|
53
|
+ map.on('zoomanim', this.onZoomAnim.bind(this));
|
52
|
54
|
},
|
53
|
55
|
|
54
|
56
|
onRemove(map) {
|
|
57
|
+ map.off('zoomanim', this.onZoomAnim.bind(this));
|
55
|
58
|
this.map = null;
|
56
|
59
|
map.removeLayer(this.layer)
|
57
|
60
|
L.GridLayer.prototype.onRemove.call(this, map);
|
|
@@ -74,6 +77,16 @@
|
74
|
77
|
return request;
|
75
|
78
|
},
|
76
|
79
|
|
|
80
|
+ onZoomAnim: function (e) {
|
|
81
|
+ var zoom = e.zoom;
|
|
82
|
+ if ((this.options.maxZoom && zoom > this.options.maxZoom) ||
|
|
83
|
+ (this.options.minZoom && zoom < this.options.minZoom)) {
|
|
84
|
+ this.map.removeLayer(this.layer);
|
|
85
|
+ } else {
|
|
86
|
+ this.map.addLayer(this.layer);
|
|
87
|
+ }
|
|
88
|
+ },
|
|
89
|
+
|
77
|
90
|
});
|
78
|
91
|
|
79
|
92
|
L.geoJSONTileLayer = function (url, options) {
|