I have an application where I have two things following the mouse cursor, a
circle (range ring) centered on the cursor and a nearby text box div that
reads out the cursor latLng.
Here is a code snippet:
function getMouseLatLong(evt){
mousePosition = evt.latLng //this is a global variable so we can know
where to place a newly-created range ring.
if(rangeRing != null){rangeRing.setCenter(mousePosition);}
var latDeg = Math.floor(mousePosition.lat());
var latMin = 60*(mousePosition.lat()-latDeg);
var latPrefix = 'N';
if (mousePosition.lat() < 0){latPrefix = 'S';}
var lonAbs = Math.abs(mousePosition.lng());
var lonDeg = Math.floor(lonAbs);
var lonMin = 60*(lonAbs-lonDeg);
var lonPrefix = 'E';
if (mousePosition.lng()<0){lonPrefix = 'W';}
//this one works for IE and doesn't seem to bother Firefox
document.getElementById('mousefollower').innerText = latPrefix + latDeg
+ ' ' + RoundTo(latMin,2) + '\n' + lonPrefix + lonDeg+ ' ' +
RoundTo(lonMin,2);
//this one works for FireFox and Chrome and doesn't seem to bother IE
document.getElementById('mousefollower').textContent = latPrefix +
latDeg + ' ' + RoundTo(latMin,2) + '\n' + lonPrefix + lonDeg+ ' ' +
RoundTo(lonMin,2) + ((rangeRing == null)?'':rangeRingDiameterLegend);
The text in the mousefollower div updates very nicely and keeps up with the
mouse movements. Even in IE8. The circle, however, has acceptable
performance only in Chrome. In IE8 and, to a slightly lesser extent in FF
3.6, it is kind of comical to see it scrambling to keep up with the mouse.
It can lag half a screen behind a fast mouse movement, then make a big jump
to catch up. During mouse movements I can see the lat/long values updating
in the div, so I know the event is firing multiple times yet the circle
seems to move only once .
Any suggestions on how to make the circle's efforts look less pathetic?
--
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.