0

我在 Firefox 中获得正确的显示/隐藏行为时遇到问题。网站在 Chrome/Safari 中运行。暂时不用担心 IE。

网站在这里:

http://chrismcaleenan.com/map/?page_id=6

当用户在 Chrome/Safari 中将鼠标悬停/鼠标移出/单击地图上的状态时,您可以看到所需的行为(忽略插图 - 这仍在进行中)。在 Firefox 中,该站点似乎可以处理鼠标悬停,但不能处理鼠标悬停或单击。

这是我认为相关的代码,尽管错误可能出现在实际的 CSS 或其他地方:

//actions on poly mouseover     
        for (var i = 0; i < statesPoly.length; i++) {
            (function(i){
                google.maps.event.addListener(eval(statesPoly[i]), 'mouseover', function() {
                    this.setOptions({ strokeWeight: '2' });
                    $("#"+statesPoly[i]).addClass("highlight");
                    if(map.getZoom() <= 6) 
                    $('#supp_data'+i).show();
                });
            })(i);
        }

        //actions on poly click     
        var zoomArray = new Array();

        for (var i = 0; i < statesPoly.length; i++) {
            zoomArray[i]=0;

            (function(i){
                google.maps.event.addListener(eval(statesPoly[i]), 'click', function() {
                    if (!zoomArray[i]) {                
                        map.panTo(eval(stateCenters[i]));
                        map.setZoom(7);
                        polyArray[i].setOptions({ fillOpacity: '0' });
                        zoomArray[i] = 1;   
                        $('#supp_data'+i).hide();
                        $('#inset-map').hide();
                    }
                    else {
                        map.panTo(myLatLng);
                        map.setZoom(6);
                        $('#inset-map').show();

                        //for some reason bug causes 11,12 to skip - adding manual reset
                        polyArray[i].setOptions({ fillOpacity: '.8' });
                        zoomArray[i] = 0;
                        polyArray[11].setOptions({ fillOpacity: '.8' });
                        zoomArray[11] = 0;
                        polyArray[12].setOptions({ fillOpacity: '.8' });
                        zoomArray[12] = 0;

                        for (n = 0; n < polyArray.length; n++) {
                            polyArray[n].setOptions({ fillOpacity: '.8' });
                            zoomArray[n] = 0;   
                        }

                    }
                });
            })(i);
        }

        //actions on table mouseover 
        for (var i = 0; i < statesPoly.length; i++) {
            (function(i){
                google.maps.event.addDomListener(document.getElementById(statesPoly[i]), 'mouseover', function() {
                    $("#"+statesPoly[i]).addClass("highlight");
                    polyArray[i].setOptions({ strokeWeight: '2' });
                    if(map.getZoom() <= 6)
                    $('#supp_data'+i).show();
                });
            })(i);
        }

        //actions on table click    
        var zoomArray = new Array();

        for (var i = 0; i < statesPoly.length; i++) {
            zoomArray[i]=0;

            (function(i){
                google.maps.event.addDomListener(document.getElementById(statesPoly[i]), 'click', function() {
                    if (!zoomArray[i]) {                
                        map.panTo(eval(stateCenters[i]));
                        map.setZoom(7);
                        polyArray[i].setOptions({ fillOpacity: '0' });
                        zoomArray[i] = 1;   
                        $('#supp_data'+i).hide();
                        $('#inset-map').hide();

                    }
                    else {
                        map.panTo(myLatLng);
                        map.setZoom(6);
                        $('#inset-map').show();


                        //for some reason bug causes 11,12 to skip - adding manual reset
                        polyArray[i].setOptions({ fillOpacity: '.8' });
                        zoomArray[i] = 0;
                        polyArray[11].setOptions({ fillOpacity: '.8' });
                        zoomArray[11] = 0;
                        polyArray[12].setOptions({ fillOpacity: '.8' });
                        zoomArray[12] = 0;

                        for (n = 0; n < polyArray.length; n++) {
                            polyArray[n].setOptions({ fillOpacity: '.8' });
                            zoomArray[n] = 0;   
                        }

                    }
                });
            })(i);
        }

        //actions on poly mouseout 
        for (var i = 0; i < statesPoly.length; i++) {
            (function(i){
                google.maps.event.addListener(eval(statesPoly[i]), 'mouseout', function() {
                    this.setOptions({ strokeWeight: '1' });
                    $("#"+statesPoly[i]).removeClass("highlight");
                    $('#supp_data'+i).hide();
                });
            })(i);
        }

        //actions on table mouseout
        for (var i = 0; i < statesPoly.length; i++) {
            (function(i){
                google.maps.event.addDomListener(document.getElementById(statesPoly[i]), 'mouseout', function() {
                    $("#"+statesPoly[i]).removeClass("highlight");
                    polyArray[i].setOptions({ strokeWeight: '1' });
                    $('#supp_data'+i).hide();
                });
            })(i);
        }
4

1 回答 1

0

解决了。我从未将我的 Poly 对象之一放入数组中。Chrome 和 Safari 继续运行该脚本,但 Firefox 将其终止(没有错误)。

于 2012-06-09T18:15:29.593 回答