Is it possible to get the coordinates of the rectangle on mouseClick, so I have all the corners of the rectangle?
To use the Leaflet. draw plugin, you need to add the js and css files to your html header, like so: <! DOCTYPE html> <html> <head> <meta charset="UTF-8"> <!
call one point of the polygon, then offset the position of the popup. Use an id for each polygon, so each popup knows the box area (polygon) it can be opened in.
Click on the map or the markers and a pop-up will show indicating if the point you clicked on, or the marker, is in the polygon. Leaflet.
See event object (http://leafletjs.com/reference.html#event-objects):
var map = L.map('map').setView([53.902257, 27.561640], 13);
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
var bounds = [[53.912257, 27.581640], [53.902257, 27.561640]];
var rect = L.rectangle(bounds, {color: 'blue', weight: 1}).on('click', function (e) {
// There event is event object
// there e.type === 'click'
// there e.lanlng === L.LatLng on map
// there e.target.getLatLngs() - your rectangle coordinates
// but e.target !== rect
console.info(e);
}).addTo(map);
Use e.target.getLatLngs()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With