Skip to content
This repository has been archived by the owner on Sep 2, 2024. It is now read-only.

Commit

Permalink
do not wait for the tiles to load to show mapbox logo
Browse files Browse the repository at this point in the history
  • Loading branch information
vcoppe committed Jan 25, 2024
1 parent e5c06f8 commit 85c506f
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions js/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,15 +616,15 @@ export default class Buttons {
boxZoom: false
}).addTo(_this.map);

_this.mapbox_logo = _this.mapboxMap._container.querySelector('.mapboxgl-ctrl');
if (_this.mapbox_logo) {
const attribution_control = document.querySelector('.leaflet-bottom.leaflet-left');
attribution_control.insertBefore(_this.mapbox_logo, attribution_control.firstChild);
}

_this.mapboxMap.getMapboxMap().on('load', () => {
_this.mapboxSKUToken = _this.mapboxMap.getMapboxMap()._requestManager._skuToken;
_this.mapboxgl_canvas = _this.mapboxMap._container.querySelector('.mapboxgl-canvas');
_this.mapbox_logo = _this.mapboxMap._container.querySelector('.mapboxgl-ctrl');
if (_this.mapbox_logo) {
const attribution_control = document.querySelector('.leaflet-bottom.leaflet-left');
attribution_control.insertBefore(_this.mapbox_logo, attribution_control.firstChild);
if (!_this.map.hasLayer(_this.mapboxMap)) _this.mapbox_logo.style.display = 'none';
}
});

baselayersHierarchy[_this.basemaps_text][_this.world_text]["Mapbox Outdoors"] = _this.mapboxMap;
Expand Down Expand Up @@ -691,7 +691,11 @@ export default class Buttons {
_this.controlLayers = L.control.layers(baselayersHierarchy, overlaysHierarchy, {editable: true}).addTo(_this.map);

if (localStorage.hasOwnProperty('lastbasemap')) {
const basemap = layers[localStorage.getItem('lastbasemap')];
const basemap_key = localStorage.getItem('lastbasemap');
if (!basemap_key.includes('mapbox')) {
_this.mapbox_logo.firstChild.style.display = 'none';
}
const basemap = layers[basemap_key];
const basemapId = _this.controlLayers.getLayerId(basemap);
if (basemapId) {
_this.controlLayers._layerControlInputs[basemapId].click();
Expand Down Expand Up @@ -2068,9 +2072,9 @@ export default class Buttons {
if (buttons.map.hasLayer(buttons.mapboxMap)) {
if (buttons.mapboxSatelliteSelector.checked) localStorage.setItem('lastbasemap', 'mapbox-satellite');
else localStorage.setItem('lastbasemap', 'mapbox');
if (buttons.mapbox_logo) buttons.mapbox_logo.style.display = '';
if (buttons.mapbox_logo) buttons.mapbox_logo.firstChild.style.display = '';
} else {
if (buttons.mapbox_logo) buttons.mapbox_logo.style.display = 'none';
if (buttons.mapbox_logo) buttons.mapbox_logo.firstChild.style.display = 'none';
}
});
window.addEventListener('beforeunload', function (e) {
Expand Down

0 comments on commit 85c506f

Please sign in to comment.