Skip to content
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

[Feature] Show zoom on map #344

Open
noneofnine opened this issue Nov 19, 2024 · 1 comment
Open

[Feature] Show zoom on map #344

noneofnine opened this issue Nov 19, 2024 · 1 comment

Comments

@noneofnine
Copy link

I wanted to see the current Zoom level in the lower left of the map above the ruler.

My crude solution was

Edit /usr/local/share/tar1090/html/script_*.js
inbetween

initFilters();
...
new Toggle({

added this code

// Create the div to display the zoom level
var zoomDiv = document.createElement('div');
zoomDiv.style.position = 'absolute';
zoomDiv.style.bottom = '30px';
zoomDiv.style.left = '10px';
zoomDiv.style.backgroundColor = 'rgba(255, 255, 255, 0.7)';
zoomDiv.style.color = 'black';
zoomDiv.style.padding = '5px';
zoomDiv.style.borderRadius = '5px';
zoomDiv.style.fontSize = '10px';
zoomDiv.style.fontFamily = 'Arial, sans-serif';
zoomDiv.style.zIndex = '1000';

// Add the zoom level div to a custom control
var zoomControl = new ol.control.Control({
    element: zoomDiv
});

// Add the control to the map
OLMap.addControl(zoomControl);

// Update the zoom level display
function updateZoomLevel() {
    var zoom = OLMap.getView().getZoom();
    var roundedZoom = zoom.toFixed(1);
    zoomDiv.innerHTML = 'Zoom: ' + roundedZoom;
}

// Initial zoom level update
updateZoomLevel();

// Update zoom level when the resolution changes (zooming in/out)
OLMap.getView().on('change:resolution', updateZoomLevel);`

This will show the zoom level in the lower left corner of the map:

ZoomLevel

I would be nice to have this build in the project.

@wiedehopf
Copy link
Owner

Guess it could be behind a config.js setting.
Because by default this shouldn't clutter the screen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants