I have simple WebSite with GoogleMaps. My GoogleMaps have mouseMove-event. All browsers everything is ok, except for IE. When I move the mouse cursor over the map - IE very much uses cpu. mouseMove-event very important for my WebSite, but because of IE it works very slowly. I google it and find same problem (Jun 2开发者_开发技巧6, 2006): gmap2 mousemove events using 100% cpu in IE. I tested it in IE6 and IE8. How I can use mouseMove and have normal speed?
I have very simple mouseMove:
// Script
GEvent.addListener(map, "mousemove", function(point) {
mousex = point.x;
mousey = point.y;
document.getElementById('LatLng').innerHTML =
'LatLng: ' + mousex + ', ' + mousey;
} );
// Body
<span id="LatLng">LatLng</span>
I think there is potential to speed it up if you use setTimeout() to ensure you only call the mousemove handler 10 times per second. Something like:
var wait = false;
GEvent.addListener(map, "mousemove", function(point) {
if (!wait) window.setTimeout("showLatLng('+point+')", 100);
wait = true;
}
function showLatLng(point) {
mousex = point.x;
mousey = point.y;
document.getElementById('LatLng').innerHTML =
'LatLng: ' + mousex + ', ' + mousey;
wait = false;
}
Haven't tested it, but it might work. Hope it does :)
精彩评论