Make sure tilelayers exist before trying to create miniMap

This commit is contained in:
Yohan Boniface 2023-08-20 18:42:30 +02:00
parent 95296f31ec
commit 9bbc901150

View file

@ -1,7 +1,7 @@
L.Map.mergeOptions({ L.Map.mergeOptions({
overlay: null, overlay: null,
datalayers: [], datalayers: [],
center: [4, 50], center: [50, 4],
zoom: 6, zoom: 6,
hash: true, hash: true,
default_color: 'DarkBlue', default_color: 'DarkBlue',
@ -85,6 +85,10 @@ L.U.Map.include({
: true : true
geojson.properties.fullscreenControl = false geojson.properties.fullscreenControl = false
L.Util.setBooleanFromQueryString(geojson.properties, 'scrollWheelZoom') L.Util.setBooleanFromQueryString(geojson.properties, 'scrollWheelZoom')
// Before calling parent initialize
if (geojson.geometry) this.options.center = this.latLng(geojson.geometry)
L.Map.prototype.initialize.call(this, el, geojson.properties) 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)
@ -96,7 +100,6 @@ L.U.Map.include({
this.name = this.options.name this.name = this.options.name
this.description = this.options.description this.description = this.options.description
this.demoTileInfos = this.options.demoTileInfos this.demoTileInfos = this.options.demoTileInfos
if (geojson.geometry) this.options.center = geojson.geometry
this.options.zoomControl = zoomControl this.options.zoomControl = zoomControl
this.options.fullscreenControl = fullscreenControl this.options.fullscreenControl = fullscreenControl
L.Util.setBooleanFromQueryString(this.options, 'moreControl') L.Util.setBooleanFromQueryString(this.options, 'moreControl')
@ -159,10 +162,12 @@ L.U.Map.include({
this.facets = {} this.facets = {}
if (this.options.hash) this.addHash() if (this.options.hash) this.addHash()
this.initTileLayers(this.options.tilelayers)
// Needs tilelayer to exist for minimap
this.initControls() this.initControls()
// Needs locate control and hash to exist
this.initCenter() this.initCenter()
this.handleLimitBounds() this.handleLimitBounds()
this.initTileLayers(this.options.tilelayers)
this.initDatalayers() this.initDatalayers()
if (this.options.displayCaptionOnLoad) { if (this.options.displayCaptionOnLoad) {