mirror of
https://github.com/umap-project/umap.git
synced 2025-05-05 22:11:50 +02:00
Alternative fix for minimap altering map center at load
This one seems to better address the issue, but it creates a new event, and we have already a lot
This commit is contained in:
parent
981f727281
commit
17b2a69b47
1 changed files with 7 additions and 6 deletions
|
@ -86,10 +86,12 @@ L.U.Map.include({
|
||||||
geojson.properties.fullscreenControl = false
|
geojson.properties.fullscreenControl = false
|
||||||
L.Util.setBooleanFromQueryString(geojson.properties, 'scrollWheelZoom')
|
L.Util.setBooleanFromQueryString(geojson.properties, 'scrollWheelZoom')
|
||||||
|
|
||||||
// Before calling parent initialize
|
L.Map.prototype.initialize.call(this, el, geojson.properties)
|
||||||
|
|
||||||
|
// After calling parent initialize, as we are doing the init center
|
||||||
|
// ourselves
|
||||||
if (geojson.geometry) this.options.center = this.latLng(geojson.geometry)
|
if (geojson.geometry) this.options.center = this.latLng(geojson.geometry)
|
||||||
|
|
||||||
L.Map.prototype.initialize.call(this, el, geojson.properties)
|
|
||||||
|
|
||||||
this.ui = new L.U.UI(this._container)
|
this.ui = new L.U.UI(this._container)
|
||||||
this.xhr = new L.U.Xhr(this.ui)
|
this.xhr = new L.U.Xhr(this.ui)
|
||||||
|
@ -162,11 +164,10 @@ L.U.Map.include({
|
||||||
this.facets = {}
|
this.facets = {}
|
||||||
|
|
||||||
if (this.options.hash) this.addHash()
|
if (this.options.hash) this.addHash()
|
||||||
|
this.initCenter()
|
||||||
this.initTileLayers(this.options.tilelayers)
|
this.initTileLayers(this.options.tilelayers)
|
||||||
// Needs tilelayer to exist for minimap
|
// Needs tilelayer to exist for minimap
|
||||||
this.initControls()
|
this.initControls()
|
||||||
// Needs locate control and hash to exist
|
|
||||||
this.initCenter()
|
|
||||||
this.handleLimitBounds()
|
this.handleLimitBounds()
|
||||||
this.initDatalayers()
|
this.initDatalayers()
|
||||||
|
|
||||||
|
@ -334,6 +335,7 @@ L.U.Map.include({
|
||||||
if (this.options.scrollWheelZoom) this.scrollWheelZoom.enable()
|
if (this.options.scrollWheelZoom) this.scrollWheelZoom.enable()
|
||||||
else this.scrollWheelZoom.disable()
|
else this.scrollWheelZoom.disable()
|
||||||
this.renderControls()
|
this.renderControls()
|
||||||
|
this.fire('controlsready')
|
||||||
},
|
},
|
||||||
|
|
||||||
renderControls: function () {
|
renderControls: function () {
|
||||||
|
@ -638,7 +640,7 @@ L.U.Map.include({
|
||||||
// FIXME An invalid hash will cause the load to fail
|
// FIXME An invalid hash will cause the load to fail
|
||||||
this._hash.update()
|
this._hash.update()
|
||||||
} else if (this.options.defaultView === 'locate' && !this.options.noControl) {
|
} else if (this.options.defaultView === 'locate' && !this.options.noControl) {
|
||||||
this._controls.locate.start()
|
this.once('controlsready', () => this._controls.locate.start())
|
||||||
} else if (this.options.defaultView === 'bounds') {
|
} else if (this.options.defaultView === 'bounds') {
|
||||||
this.onceDataLoaded(() => this.fitBounds(this.getLayersBounds()))
|
this.onceDataLoaded(() => this.fitBounds(this.getLayersBounds()))
|
||||||
} else if (this.options.defaultView === 'latest') {
|
} else if (this.options.defaultView === 'latest') {
|
||||||
|
@ -648,7 +650,6 @@ L.U.Map.include({
|
||||||
if (feature) feature.zoomTo()
|
if (feature) feature.zoomTo()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.options.center = this.latLng(this.options.center)
|
|
||||||
this.setView(this.options.center, this.options.zoom)
|
this.setView(this.options.center, this.options.zoom)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue