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

Doesn't work with image overlays #108

Open
vondermanzen opened this issue Mar 20, 2024 · 1 comment
Open

Doesn't work with image overlays #108

vondermanzen opened this issue Mar 20, 2024 · 1 comment

Comments

@vondermanzen
Copy link

vondermanzen commented Mar 20, 2024

I tried to measure a wall, unfortunately, the lines are displayed outside the map and not where I clicked

image

image

This is how I create my map

var map = L.map('map', {
crs: L.CRS.Simple,
attributionControl: false,
noWrap: true,
continuousWorld: true, 
minZoom: -5,
zoomDelta: 0.2,
zoomSnap: 0.2,
wheelPxPerZoomLevel: 300
});

// Add a custom .bmp image layer
var imageBounds = [[0, 0], [size.height, size.width]];
L.imageOverlay(imageUrl, imageBounds, {
noWrap: true,
continuousWorld: true
}).addTo(map);

// Fit the bounds to the image size
map.fitBounds(imageBounds);
map.setZoom(0); 



options = {
position: 'topleft',            // Position to show the control. Values: 'topright', 'topleft', 'bottomright', 'bottomleft'
};

L.control.polylineMeasure(options).addTo(map);
@dankarran
Copy link

I think for this to work with overlays you'd need to set the bounds to proper geographic coordinates.

L.imageOverlay expects a LatLngBounds object to be passed in, but you're just passing in the pixel size of the image in your imageBounds variable.

Once Leaflet knows how to place your image then you should be able to measure off it.

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