-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Idea about how to detect whether a layer is actually showing something in the current view extent #278
Comments
@mapcentia Could you please specify if this feature supposed to be working only for |
@mapcentia yes |
@mapcentia Leaflet uses |
Following script answers the question $('canvas').each((index, canvas) => {
let canvasHasData = false;
let data = canvas.getContext('2d').getImageData(0, 0, canvas.width, canvas.height).data;
for (let key in data) {
if (data[key] !== 0) {
console.log('First not 0 value for ' + index + ' (' + data[key] + '), exiting');
canvasHasData = true;
break;
}
}
console.log('Canvas ' + index + ' has data: ' + canvasHasData);
}); Problems:
Researching further |
@mapcentia Whenever tile layer is loaded, its canvas is checked for data (if there is data, then the green 👁️ icon appears near the layer name). When user moves away (including the buffer), then icon becomes hidden. The code is in separate branch https://github.com/sashuk/vidi/tree/tile-content or you can test it at https://vidi.alexshumilov.ru/app/aleksandrshumilov/public/#stamenTonerLite/4/60.293/35.8534/public.polygons However, the solution (1) makes application very slow and (2) buffered data (which can be already hidden from user) is taken into account anyway. For now I have not found how to get the part of |
Vidi users have requested a visual indication of whether a layer is actually showing something in the current view extent. An idea is to check the bitmap tile of a layer for transparency. If it's 100% transparent a visual indicator in the layer tree will be switch on.
Could this be done using a canvas element?
The text was updated successfully, but these errors were encountered: