leaflet - tile loading - error event -



leaflet - tile loading - error event -

i using leaflet displays offline tiles have been created using maperitive. works fine know how trigger error event in case requested tile not exist? in case requested tile cannot loaded, can specify default tile.

var mylayer = new l.tilelayer(..., {errortileurl: '/path/to/default/tile.png'});

which sets default tile if there error loading requested tile. not need. need fire event.

the leaflet code pretty simple.

l.tilelayer('http://{s}.tiles.mapbox.com/v3/mapid/{z}/{x}/{y}.png', { attribution: 'map info &copy; <a href="http://openstreetmap.org">openstreetmap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">cc-by-sa</a>, imagery © <a href="http://mapbox.com">mapbox</a>', maxzoom: 18 }).addto(map);

mylayer.on('tileerror', function(error, tile) { console.log(error); console.log(tile); });

ref: https://github.com/leaflet/leaflet/blob/v0.7.3/src/layer/tile/tilelayer.js#l581

does help ?

leaflet

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -