Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

hack to work in leaflet 0.7.3 #8

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions leaflet.wms.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,24 @@
// Module object
var wms = {};

// Hacky backport of L.Layer for 0.7.3
if (!L.Layer) {
L.Layer = L.LayerGroup.extend({
'onAdd': function(map) {
this._map = map;
if (map && this.getEvents) {
var events = this.getEvents();
for (var evt in events) {
map.on(evt, events[evt], this);
}
}
},
'onRemove': function() {
delete this._map;
}
});
}

/*
* wms.Source
* The Source object manages a single WMS connection. Multiple "layers" can be
Expand Down Expand Up @@ -53,7 +71,8 @@ wms.Source = L.Layer.extend({
}
},

'onAdd': function() {
'onAdd': function(map) {
L.Layer.prototype.onAdd.call(this, map);
this.refreshOverlay();
},

Expand Down Expand Up @@ -85,7 +104,7 @@ wms.Source = L.Layer.extend({
return;
}
if (!subLayers) {
this._overlay.remove();
this._map.removeLayer(this._overlay);
} else {
this._overlay.setParams({'layers': subLayers});
this._overlay.addTo(this._map);
Expand Down Expand Up @@ -207,7 +226,8 @@ wms.Layer = L.Layer.extend({
this._source = source;
this._name = layerName;
},
'onAdd': function() {
'onAdd': function(map) {
L.Layer.prototype.onAdd.call(this, map);
if (!this._source._map)
this._source.addTo(this._map);
this._source.addSubLayer(this._name);
Expand Down Expand Up @@ -284,7 +304,8 @@ wms.Overlay = L.Layer.extend({
return this.options.attribution;
},

'onAdd': function() {
'onAdd': function(map) {
L.Layer.prototype.onAdd.call(this, map);
this.update();
},

Expand All @@ -296,6 +317,7 @@ wms.Overlay = L.Layer.extend({
if (this._currentUrl) {
delete this._currentUrl;
}
L.Layer.prototype.onRemove.call(this, map);
},

'getEvents': function() {
Expand Down
Loading