I am trying to convert a mouse position on a google map to a LatLng object. I see quite a lot of messages about getting a position using the google map "click" event, etc., For example:
google.maps.event.addListener(map, 'click', function(event) { mouseLocation = event.latLng; });
But this does not work for my purposes, because I do not respond to the map event, I respond to the 'tapHold' event. Inside the tapHold event, I would like to get the latitude and longitude of the current mouse position. In fact, I could see that such a function is useful in many ways besides just the tapHold event.
I can think of some hacks, for example, creating a mouseover event on the fly, and then resolving it only once and removing it after receiving the LatLng object from the rollover event, but it seems to be hacky to me ... Looking for a more elegant solution. Thanks!
javascript google-maps geolocation
botbot
source share