diff --git a/leaflet.rrose-src.js b/leaflet.rrose-src.js index 0550f26..2a2d513 100644 --- a/leaflet.rrose-src.js +++ b/leaflet.rrose-src.js @@ -23,21 +23,33 @@ L.Rrose = L.Popup.extend({ closeButton, wrapper; // Set the pixel distances from the map edges at which popups are too close and need to be re-oriented. - var x_bound = 80, y_bound = 80; + var xBound, yBound; + if (this.options.xBound) { + xBound = this.options.xBound; + } + else { + xBound = 80; + } + if (this.options.yBound) { + yBound = this.options.yBound; + } + else { + yBound = 80; + } // Determine the alternate direction to pop up; north mimics Leaflet's default behavior, so we initialize to that. this.options.position = 'n'; // Then see if the point is too far north... - var y_diff = y_bound - this._map.latLngToContainerPoint(this._latlng).y; + var y_diff = yBound - this._map.latLngToContainerPoint(this._latlng).y; if (y_diff > 0) { this.options.position = 's' } // or too far east... - var x_diff = this._map.latLngToContainerPoint(this._latlng).x - (this._map.getSize().x - x_bound); + var x_diff = this._map.latLngToContainerPoint(this._latlng).x - (this._map.getSize().x - xBound); if (x_diff > 0) { this.options.position += 'w' } else { // or too far west. - x_diff = x_bound - this._map.latLngToContainerPoint(this._latlng).x; + x_diff = xBound - this._map.latLngToContainerPoint(this._latlng).x; if (x_diff > 0) { this.options.position += 'e' }