From eb3b4052ba755a315e81c66acfcc68ea6eb3998d Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 15 Jan 2013 13:50:51 +0100 Subject: [PATCH 1/2] Add "include" Leaflet API for addind methods to L.Map --- leaflet-hash.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/leaflet-hash.js b/leaflet-hash.js index b2759c5..6fa1c87 100644 --- a/leaflet-hash.js +++ b/leaflet-hash.js @@ -143,13 +143,18 @@ this.isListening = false; } }; + L.hash = function(map){ - return new L.Hash(map); + return new L.Hash(map); }; - L.Map.prototype.addHash = function(){ - this._hash = L.hash(this); - }; - L.Map.prototype.removeHash = function(){ - this._hash.remove(); - } + + L.Map.include({ + addHash: function(){ + this._hash = L.hash(this); + }, + + removeHash: function(){ + this._hash.remove(); + } + }); })(window); \ No newline at end of file From 34ae537b9bab5ac232b0f9738b10fd97bbee10e1 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Tue, 15 Jan 2013 16:00:59 +0100 Subject: [PATCH 2/2] Make addHash and removeHash chainable --- leaflet-hash.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/leaflet-hash.js b/leaflet-hash.js index 6fa1c87..d4239df 100644 --- a/leaflet-hash.js +++ b/leaflet-hash.js @@ -151,10 +151,12 @@ L.Map.include({ addHash: function(){ this._hash = L.hash(this); + return this; }, removeHash: function(){ - this._hash.remove(); + this._hash.remove(); + return this; } }); })(window); \ No newline at end of file