IE中的GoogleMaps存在奇怪的速度问题

时间:2010-01-28 19:17:03

标签: internet-explorer google-maps

我有简单的WebSite和GoogleMaps。我的GoogleMaps有mouseMove-event。所有浏览器一切正常,IE除外。当我将鼠标光标移动到地图上时 - IE非常使用cpu。 mouseMove-event对于我的WebSite非常重要,但由于IE它的工作速度非常慢。我谷歌并发现同样的问题(2006年6月26日):gmap2 mousemove events using 100% cpu in IE。我在IE6和IE8中测试过它。我如何使用mouseMove并具有正常速度?

我有一个非常简单的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>

1 个答案:

答案 0 :(得分:1)

如果你使用setTimeout()来确保你每秒只调用mousemove处理程序10次,我认为有可能加快速度。类似的东西:

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;
}

没有测试过,但可能会有效。希望它能:)