Set default center in case of location error at load
This commit is contained in:
parent
9c16bbfe51
commit
e636ced4c6
1 changed files with 8 additions and 2 deletions
|
@ -310,6 +310,7 @@ L.U.Map.include({
|
||||||
icon: 'umap-fake-class',
|
icon: 'umap-fake-class',
|
||||||
iconLoading: 'umap-fake-class',
|
iconLoading: 'umap-fake-class',
|
||||||
flyTo: this.options.easing,
|
flyTo: this.options.easing,
|
||||||
|
onLocationError: (err) => this.ui.alert({content: err.message})
|
||||||
})
|
})
|
||||||
this._controls.fullscreen = new L.Control.Fullscreen({
|
this._controls.fullscreen = new L.Control.Fullscreen({
|
||||||
title: { false: L._('View Fullscreen'), true: L._('Exit Fullscreen') },
|
title: { false: L._('View Fullscreen'), true: L._('Exit Fullscreen') },
|
||||||
|
@ -632,11 +633,17 @@ L.U.Map.include({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_setDefaultCenter: function () {
|
||||||
|
this.options.center = this.latLng(this.options.center)
|
||||||
|
this.setView(this.options.center, this.options.zoom)
|
||||||
|
},
|
||||||
|
|
||||||
initCenter: function () {
|
initCenter: function () {
|
||||||
if (this.options.hash && this._hash.parseHash(location.hash)) {
|
if (this.options.hash && this._hash.parseHash(location.hash)) {
|
||||||
// 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.once('locationerror', this._setDefaultCenter)
|
||||||
this._controls.locate.start()
|
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()))
|
||||||
|
@ -647,8 +654,7 @@ L.U.Map.include({
|
||||||
if (feature) feature.zoomTo()
|
if (feature) feature.zoomTo()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this.options.center = this.latLng(this.options.center)
|
this._setDefaultCenter()
|
||||||
this.setView(this.options.center, this.options.zoom)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue