Z
Z
zlodiak2018-07-30 13:50:38
JavaScript
zlodiak, 2018-07-30 13:50:38

How to convert cursor coordinates to latitude/longtitude?

There is a map. I hung a handler for mouse movement like this:

document.getElementById('map').addEventListener("mousemove", (e) => {
  console.log(e.clientX, e.clientY);
  console.log(this.widgetMap.converter.pageToGlobal([e.clientX, e.clientY]))
});

As you can see, I'm trying to convert the coordinates of a point on the screen to latitude/longtitude. but as a result for a real point c
[55.780739, 49.127621]
I get the result
[10678127.080786489, 5257339.447339956]
Please help me to get the correct latitude/longtitude values.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Victor L, 2018-07-30
@zlodiak

What map do you work with Google or Yandex Both have excellent documentation

google.maps.event.addListener(map, "click", function (e) {

    //lat and lng is available in e object
    var latLng = e.latLng;

});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question