move closePopupOnClick to Map

This commit is contained in:
Mourner 2011-01-10 13:06:22 +02:00
parent ba8c690751
commit d6dc8acd04
3 changed files with 7 additions and 8 deletions

View File

@ -3,8 +3,7 @@ L.Popup = L.Class.extend({
includes: L.Mixin.Events,
options: {
maxWidth: 300,
closeOnClick: true
maxWidth: 300
},
initialize: function() {
@ -23,11 +22,6 @@ L.Popup = L.Class.extend({
map.on('viewreset', this._updatePosition, this);
if (this.options.closeOnClick) {
map.on('click', map.closePopup, map);
//TODO move closeOnClick to Map
}
this._container.style.visibility = 'hidden';
this._updateLayout();
this._updatePosition();

View File

@ -3,6 +3,10 @@ L.Map.include({
openPopup: function(latlng, content, offset) {
if (!this._popup) {
this._popup = new L.Popup();
if (this.options.closePopupOnClick) {
this.on('click', this.closePopup, this);
}
} else {
this.removeLayer(this._popup);
}

View File

@ -23,7 +23,8 @@ L.Map = L.Class.extend({
doubleClickZoom: true,
//misc
trackResize: true
trackResize: true,
closePopupOnClick: true
},