Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Leaflet tile layers accessible

How can you add an 'alt' tag to tile layers, and raise the accessibility score of an application, in particular to the Esri.WorldGrayCanvas, but any of the tiles found at http://leaflet-extras.github.io/leaflet-providers/preview/?

like image 883
geospatialem Avatar asked Dec 31 '25 09:12

geospatialem


1 Answers

You could manipulate the tile images when they load by hooking into the tileload event:

esriGray.on('tileload', function (tileEvent) {
    tileEvent.tile.setAttribute('alt', 'Map tile image');
});

That way the images always have the alt tag, even after zoom/pan and you don't have to use Jquery.

like image 143
iH8 Avatar answered Jan 03 '26 07:01

iH8



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!