Hi Luke,
Never mind. This does it:
google.maps.event.addListener(map, 'mousemove' ,function(event)
{var myLat = event.latLng.lat();
var myLon = event.latLng.lng();
var myLoc = "Lat: " + RoundTo(myLat,5) + ", Lon: " +
RoundTo(myLon,5);
document.getElementById('mapLoc').innerHTML = myLoc;
} );
//--------------------------------------------------
function RoundTo(myVar, numDP) {
myFactor = Math.pow(10, numDP);
return Math.round(myVar * myFactor) / myFactor;
}
putting the cursor location into this div:
<div style="padding:.3em; background-color: #324164; color:
white"><b>Cursor location: </b><span id="mapLoc"></span></div>
-Steve
On Mar 2, 7:45 am, shsavage <[email protected]> wrote:
> Hi Luke,
>
> So far I've not had any luck getting the mouse location in response
> to the mousemove event. I have tried it this way:
>
> google.maps.event.addListener(map, 'mousemove', reportLoc);
>
> and this:
>
> google.maps.event.addListener(map, 'mousemove', function()
> {reportLoc(event);});
>
> where reportLoc does this:
>
>
> //------------------------------------------------------------------------------------
> function reportLoc(event) {
> var myLoc = RoundTo(event.latLon.lat(),5) + ", " +
> RoundTo(event.latLng.lng(),5);
> document.getElementById('mapLoc').innerHTML = 'Location: ' +
> myLoc;
> }
>
> and in both cases, I get an error that "latLng is not an object" in
> the reportLoc function. What am i doing wrong here?
>
> Thanks,
>
> -Steve
>
> On Feb 26, 12:08 pm, "Luke (Google Employee)" <[email protected]>
> wrote:
>
>
>
> > Hey everyone!
>
> > We've recently pushed out a new version of the API. See the list of
> > changes
> > below:http://code.google.com/p/gmaps-api-issues/wiki/JavascriptMapsAPIv3Cha...
>
> > Changed Issues:
> > - Issue 1651: Added mousemove/mouseout/mouseover to the Map.
> > - Issue 2142: Options added to DirectionsRenderer for suppressing
> > overlays and changing marker/polygon styles.
> > - Issue 2148: Fixed polygon click event bug where latLng was
> > obfuscated to .Hk.
> > - Issue 2109: Fixed Navigation controls not rendering correctly in IE.
> > - Issue 2153: MVCArray.push() now returns the new length.
>
> > Noticeable Changes:
> > - Add opacity to ImageMapType.
> > - Fixed the bug where rightclick on a rectangle/circle was not being
> > fired.
> > - Info window's content events are no longer being removed on hide.
>
> > Please test and provide feedback.
>
> > Thanks!
>
> > Luke- Hide quoted text -
>
> - Show quoted text -
--
You received this message because you are subscribed to the Google Groups
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-js-api-v3?hl=en.