From ae07e792af38018bcc7dfc50caf4e7f9dd0aa0cd Mon Sep 17 00:00:00 2001 From: snkashis Date: Thu, 14 Feb 2013 23:04:53 -0500 Subject: [PATCH] Allow previously created popups to be used with bindPopup --- debug/tests/reuse_popups.html | 41 ++++++++++++++++++++++++++++++++ src/layer/marker/Marker.Popup.js | 9 +++++-- 2 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 debug/tests/reuse_popups.html diff --git a/debug/tests/reuse_popups.html b/debug/tests/reuse_popups.html new file mode 100644 index 00000000..c202ecab --- /dev/null +++ b/debug/tests/reuse_popups.html @@ -0,0 +1,41 @@ + + + + Leaflet debug page + + + + + + + + + +
+ + + + \ No newline at end of file diff --git a/src/layer/marker/Marker.Popup.js b/src/layer/marker/Marker.Popup.js index 2171bbff..ec882efd 100644 --- a/src/layer/marker/Marker.Popup.js +++ b/src/layer/marker/Marker.Popup.js @@ -37,8 +37,13 @@ L.Marker.include({ .on('move', this._movePopup, this); } - this._popup = new L.Popup(options, this) - .setContent(content); + if (content instanceof L.Popup) { + L.setOptions(content, options); + this._popup = content; + } else { + this._popup = new L.Popup(options, this) + .setContent(content); + } return this; },