nanocube
nanocube copied to clipboard
Obtain Coordinates of Polygon Corners
According to our project, we would like to know the coordinates of the polygon corners while the user is drawing it, in particular on click event on the map; so we would like to use this code of the library Leaflet JS or something similar:
L.ClickHandler = L.Handler.extend({
addHooks: function() {
L.DomEvent.on(document, 'click', this._captureClick, this);
},
removeHooks: function() {
L.DomEvent.off(document, 'click', this._captureClick, this);
},
_captureClick: function(event) {
latElong = mymap.mouseEventToLatLng(event)
alert(mymap.mouseEventToLatLng(event))
return latElong
}
});
L.Map.addInitHook('addHandler', 'click', L.ClickHandler);
var mymap = L.map('mapid', {
click: true
}).setView([51.505, -0.09], 13);
and obtaining a similar result:
Our question is: where could we insert this function in your project? Where and how is defined the map in your project?
Thank you for your attention Best regards, Nicholas