mousemove event on map

627 views
Skip to first unread message

shsavage

unread,
Oct 15, 2009, 4:10:13 PM10/15/09
to Google Maps JavaScript API v3
Hi,

In the older versions of GM, there was a mousemove event on the map
itself that could be listened for in order to report the mouse
location. I don't see that event in the v 3.0 documentation. A
mousemove event seems only to be attached to polylines and polygons.
Is there another way to fetch the coordinates as the mouse moves over
the map?

Thanks,

-Steve

Paul Kulchenko

unread,
Oct 16, 2009, 12:35:09 AM10/16/09
to Google Maps JavaScript API v3
You mean something like this: http://notebook.kulchenko.com/maps/gridmove?

This has been recently discussed in this thread:
http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/1b2914847d91bbe5#.
There are also feature requests for this and related features
referenced in that thread that you can star.

Paul (http://notebook.kulchenko.com/maps/)

shsavage

unread,
Oct 16, 2009, 12:50:30 PM10/16/09
to Google Maps JavaScript API v3
Hi Paul,

Under v2.x it was possible with something as simple as this:

GEvent.addListener(map,'mousemove',function(latlng)
{ var myLat = latlng.lat();
var myLon = latlng.lng();
var myLoc = RoundTo(myLat,5) + ", " + RoundTo(myLon,5);
parent.data.form.elements[1].value = myLoc;} );


Now I can't figure out a simple way to do it in v3. Using the Canvas
approach is far more complicated that I need the application to be.

-Steve

On Oct 15, 9:35 pm, Paul Kulchenko <paulclin...@gmail.com> wrote:
> You mean something like this:http://notebook.kulchenko.com/maps/gridmove?
>
> This has been recently discussed in this thread:http://groups.google.com/group/google-maps-js-api-v3/browse_thread/th....
> There are also feature requests for this and related features
> referenced in that thread that you can star.
>
> Paul (http://notebook.kulchenko.com/maps/)
>
> On Oct 15, 1:10 pm, shsavage <shsav...@asu.edu> wrote:
>
>
>
> > Hi,
>
> >    In the older versions of GM, there was a mousemove event on the map
> > itself that could be listened for in order to report the mouse
> > location.  I don't see that event in the v 3.0 documentation.  A
> > mousemove event seems only to be attached to polylines and polygons.
> > Is there another way to fetch the coordinates as the mouse moves over
> > the map?
>
> > Thanks,
>
> > -Steve- Hide quoted text -
>
> - Show quoted text -

Paul Kulchenko

unread,
Oct 16, 2009, 2:22:33 PM10/16/09
to Google Maps JavaScript API v3
Steve,

I'm aware of how this is done in v2, but this functionality doesn't
(yet) exist in v3 and I wanted something that works in both versions.
There is a feature request you can star:
http://code.google.com/p/gmaps-api-issues/issues/detail?id=1651

Until it's implemented by Google you can use the mechanism similar to
what I showed, which is essentially: 1. register addDomListener to
whatever element works for you across browsers, 2. capture mouse X/Y
coordinates 3. convert them to absolute coordinates 4. convert those
to Lat/Lng. It doesn't need to use canvas; it's just something I
already had working.

Paul (http://notebook.kulchenko.com/maps/)
Reply all
Reply to author
Forward
0 new messages