谷歌地图在本地工作,但当我搬到现场它显示空白页面

时间:2013-12-06 06:38:57

标签: javascript php google-maps

当我将其更改为显示为空时,这在本地工作正常。 这里我们在这段代码中还有其他东西吗?我的意思是在php或地图画布

<style type="text/css">
                body { font: normal 10pt Helvetica, Arial; }
                #map { width: 350px; height: 300px; border: 0px; padding: 0px; }
            </style>
            <script src="http://maps.google.com/maps/api/js?&sensor=false" type="text/javascript"></script>
            <script type="text/javascript">
                //Sample code written by August Li
                var icon = new google.maps.MarkerImage("http://maps.google.com/mapfiles/ms/micons/blue.png",
                           new google.maps.Size(32, 32), new google.maps.Point(0, 0),
                           new google.maps.Point(16, 32));
                var center = null;
                var map = null;
                var currentPopup;
                var bounds = new google.maps.LatLngBounds();
                function addMarker(lat, lng, info) {
                    var pt = new google.maps.LatLng(lat, lng);
                    bounds.extend(pt);
                    var marker = new google.maps.Marker({
                        position: pt,
                        icon: icon,
                        map: map
                    });
                    var popup = new google.maps.InfoWindow({
                        content: info,
                        maxWidth: 300
                    });
                    google.maps.event.addListener(marker, "click", function() {
                        if (currentPopup != null) {
                            currentPopup.close();
                            currentPopup = null;
                        }
                        popup.open(map, marker);
                        currentPopup = popup;
                    });
                    google.maps.event.addListener(popup, "closeclick", function() {
                        map.panTo(center);
                        currentPopup = null;
                    });
                }           
                function initMap() {
                    map = new google.maps.Map(document.getElementById("map"), {
                        center: new google.maps.LatLng(0, 0),
                        zoom: 14,
                        mapTypeId: google.maps.MapTypeId.ROADMAP,
                        mapTypeControl: true,
                        mapTypeControlOptions: {
                            style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
                        },
                        navigationControl: true,
                        navigationControlOptions: {
                            style: google.maps.NavigationControlStyle.ZOOM_PAN
                        }
                    });
    <?php
    // here $product_info['products_state']=state code
    $query = mysql_query("SELECT * FROM states where abv = '" .$product_info['products_state']. "'")or die(mysql_error());

    while($row = mysql_fetch_array($query))
    {
      $name = $row['name'];
      $lat = $row['latitude'];
      $lon = $row['longitude'];
      $desc = $row['abv'];



      echo("addMarker($lat, $lon, '<b>$name</b><br />$desc');\n");

    }

    ?>
     center = bounds.getCenter();
         map.fitBounds(bounds);

         }
         </script>
         </head>
         <body onLoad="initMap()" style="margin:0px; border:0px; padding:0px;">
         <div id="map"></div>
         </body>

为此我在这里添加了任何api代码?我在哪里可以把我的api?

1 个答案:

答案 0 :(得分:0)

将彩色边框(通过开发人员工具)添加到地图div,并检查它是否没有被任何其他HTML元素所掩盖。使用浏览器错误控制台检查页面渲染时是否存在任何javascript错误。