我在地图上有 3 个图层,但是当我选择并刷新地图时,它总是显示 默认一种任何方式显示用户选择的地图,即使页面重新加载
var defaultMap = window.L.tileLayer(
'https://stamen-tiles-{s}.a.ssl.fastly.net/terrain-background/{z}/{x}/{y}{r}.{ext}',
{
attribution: `Map tiles by <a href="http://stamen.com" target="_blank" class="attribution">Stamen Design<span class="warning bg-c-gray-800 c-border-dark">${this.opensInNewWindowLbl}</span></a>,
<a href="http://creativecommons.org/licenses/by/3.0" target="_blank" class="attribution">CC BY 3.0<span class="warning bg-c-gray-800 c-border-dark">${this.opensInNewWindowLbl}</span></a> — Map data ©
<a href="https://www.openstreetmap.org/copyright" target="_blank" class="attribution">OpenStreetMap<span class="warning bg-c-gray-800 c-border-dark">${this.opensInNewWindowLbl}</span></a> contributors`
}
).addTo(this.map);
var stamen = L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/toner-background/{z}/{x}/{y}{r}.{ext}', {
attribution: 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
subdomains: 'abcd',
minZoom: 0,
maxZoom: 20,
ext: 'png'
});
var esri = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community'
});
//leaflet layer Control
var baseMaps = {
'Open Street Maps': defaultMap,
'High Contrast': stamen,
'Setalite view': esri,
}
L.control.layers(baseMaps).addTo(this.map);