Getting map coordinates from Leaflet.js?
<p>I'm trying to use Leaflet to get the map coordinates of somewhere a user has right clicked. I've been going through the Leaflet API and so far I've figured out that I need to listen to the <code>contextmenu</code> event and use <code>mouseEventToLatLng</code> <a href="http://leafletjs.com/reference.html#map-mouseeventtolatlng" rel="noreferrer">method</a> to get the coordinates when clicked. However, when I go through and debug my code I'm not seeing an accessible latLng variable anywhere. Did I miss understand something in the API? </p>

<pre><code>function setMarkers() {
        document.getElementById("transitmap").addEventListener("contextmenu", function( event ) {
            // Prevent the browser's context menu from appearing
            event.preventDefault();

            var coords = L.mouseEventToLatLng( event );
        });
    };
</code></pre>