我了解Leaflet瓦片图层的tileerror
事件,但如果瓦片只是带有“无地图数据”免责声明的虚拟瓦片,则不会触发该事件。
var map = L.map("map").setView([52.21581894148382, 2.74709701538086], 14);
var layer = 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'
});
layer.addTo(map);
layer.on("tileerror", function() {
console.log("An error occurred while trying to load a tine...");
});
#map { height: 98vh; }
<link href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css" rel="stylesheet"/>
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"></script>
<div id="map"></div>