hack to prevent minimap to change map center at load

This commit is contained in:
Yohan Boniface 2023-08-24 16:56:37 +02:00
parent 981f727281
commit fe20489950
2 changed files with 9 additions and 2 deletions

View file

@ -1365,12 +1365,19 @@ L.U.SearchControl = L.Control.extend({
}, },
}) })
L.Control.MiniMap.include({ L.U.MiniMap = L.Control.MiniMap.extend({
initialize: function (layer, options) { initialize: function (layer, options) {
L.Util.setOptions(this, options) L.Util.setOptions(this, options)
this._layer = this._cloneLayer(layer) this._layer = this._cloneLayer(layer)
}, },
onAdd: function (map) {
L.Control.MiniMap.prototype.onAdd.call(this, map);
// Prevent the MiniMap to send a moveend at init
this._mainMapMoving = true
return this._container
},
onMainMapBaseLayerChange: function (e) { onMainMapBaseLayerChange: function (e) {
const layer = this._cloneLayer(e.layer) const layer = this._cloneLayer(e.layer)
if (this._miniMap.hasLayer(this._layer)) { if (this._miniMap.hasLayer(this._layer)) {

View file

@ -357,7 +357,7 @@ L.U.Map.include({
if (this.options.miniMap && !this.options.noControl) { if (this.options.miniMap && !this.options.noControl) {
this.whenReady(function () { this.whenReady(function () {
if (this.selected_tilelayer) { if (this.selected_tilelayer) {
this._controls.miniMap = new L.Control.MiniMap(this.selected_tilelayer).addTo( this._controls.miniMap = new L.U.MiniMap(this.selected_tilelayer).addTo(
this this
) )
this._controls.miniMap._miniMap.invalidateSize() this._controls.miniMap._miniMap.invalidateSize()