Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Coordinate (latitude, longitude) from mouse position
posted

I want to find coordinate from mouse position on the map. Is it possible?

Parents
  • 775
    Suggested Answer
    posted

    Hello Eugen,

        There are several ways to get the mouse position on the map – it just depends when you want to do it. For example, you can do it when you click somewhere on the map. In that case you can use the following code:

    $("#map").bind("click", function(event) {

        console.log("X: " + event.clientX + ", Y: " + event.clientY);

    });

    The event.clientX and event.clientY properties will return the mouse X and Y position respectively when you click over the map.

    If you need to get those values in another event, then you can use the same code, shown above, just change the event name from “click” to whatever you need.

    Hope this is what you need,

    Martin Stoev

Reply Children
No Data