nanocube icon indicating copy to clipboard operation
nanocube copied to clipboard

Obtain Coordinates of Polygon Corners

Open Vzzarr opened this issue 7 years ago • 0 comments

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: image

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

Vzzarr avatar Jul 03 '17 12:07 Vzzarr