谷歌地图没有在Firefox中显示

时间:2013-11-20 18:44:55

标签: javascript html google-maps

它在chrome中运行良好。但是当由firefox加载时,谷歌地图的右侧将留空。它似乎所有代码功能都可以正常工作(Spring mvc和Jquery) 您还可以在sameplaces.heroku.com中查看该应用程序。感谢

 <html>
<head>
    <link rel="stylesheet" href="resources/development-bundle/themes/base/jquery.ui.all.css">
    <script type="text/javascript" src="resources/js/jquery-1.9.1.js"></script>
    <script src="resources/development-bundle/ui/jquery.ui.core.js"></script>
    <script src="resources/development-bundle/ui/jquery.ui.widget.js"></script>
    <script src="resources/development-bundle/ui/jquery.ui.button.js"></script> 
    <link rel="stylesheet" type="text/css" href="resources/css/layout.css"/>
    <script type="text/javascript"
      src="https://maps.googleapis.com/maps/api/js?key=AIzaSyA8_h_OaZwi_KRiDev5M8PUxhKRuKbOj1Q&sensor=true">
    </script>
    <script type="text/javascript">
      $(function(){
            $("input[type=submit],input[type=button],a,button")
                .button()
                .click(function(event){
                    event.preventDefault();
                });
      });
      var initialLocation;
      var siberia = new google.maps.LatLng(60, 105);
      var newyork = new google.maps.LatLng(40.69847032728747, -73.9514422416687);
      var browserSupportFlag =  new Boolean();
      function initialize() {
        var mapOptions = {
          zoom: 13,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map-canvas"),
            mapOptions);
        if(navigator.geolocation) {
          browserSupportFlag = true;
          navigator.geolocation.getCurrentPosition(function(position) {
          initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude);
          map.setCenter(initialLocation);
          }, function() {
            handleNoGeolocation(browserSupportFlag);
          });
        }
        // Browser doesn't support Geolocation
        else {
          browserSupportFlag = false;
          handleNoGeolocation(browserSupportFlag);
        }

        function handleNoGeolocation(errorFlag) {
          if (errorFlag == true) {
            alert("Geolocation service failed.");
            $(".address_search_div").show();
            initialLocation = newyork;
          } else {
              alert("Your browser doesn't support geolocation. We've placed you in Siberia.");
              initialLocation = siberia;
            }
        map.setCenter(initialLocation);
        }
      }
      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
</head>
<body>
    <table width="100%" height="100%">
        <tr>
            <td width="35%" height="100%"><t:insertAttribute name="menu"/></td>
            <td width="65%" height="100%"><t:insertAttribute name="map"/></td>
        </tr>
    </table>
</body>
</html>

1 个答案:

答案 0 :(得分:2)

我在Chrome和FF上都有效。我摆脱了你的所有CSS和jquery包括简化一切。我加入了这种风格:

    html { height: 100% }
    body { height: 100%; margin: 0; padding: 0 }
    #map-canvas { height: 100% }

Chrome还行,FF报道:

Error in parsing value for 'background'. Declaration dropped.
   -webkit-linear-gradient(left, #000, #fff)

解决方案是这种造型(缺少宽度):

<style type="text/css">
  html { height: 100% ; width: 100%}
  body { height: 100%; width:100%; margin: 0; padding: 0 }
  #map-canvas { height: 100%; width:100% }
</style>

此解决方案的说明是Google Maps V3 Polyline loading fails。请注意,背景信息相同。

所以,检查你的造型。似乎代码没问题。