谷歌地图不会显示在8或9

时间:2014-03-31 17:55:11

标签: javascript google-maps

我不知道它为什么没有显示。我可以 不要让它显示在6-9,有没有人有任何想法?

我认为它可能是javascript,但我不确定,JQuery是旧版本,所以我不认为这是问题所在。

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" href="css/Style.css" type="text/css" />

    <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCOG1bujdUBiEwXHJZttZU1H87Zwd4HTRQ&sensor=false"></script>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
    <![if !IE]>
    <script language="javascript" type="text/javascript" src="Path/to/excanvas.min.js"></script>
<![endif]>

    <script type="text/javascript">

var markerDisplay = [];
var iconDisplay = [];
var panelAddresses = [];
var zipGroup = 0;
var infowindow;

function initializeMap() {

    geoCoder = new google.maps.Geocoder();
    //address = document.getElementById("ID_txtDocters").value;
   var address = "United States, 85716";
   var lat = '';
   var lng = '';
   geoCoder.geocode({ 'address': address }, function (results, status) {
       if (status == google.maps.GeocoderStatus.OK) {
           lat = results[0].geometry.location.lat();
           lng = results[0].geometry.location.lng();

           var options =
           {
               zoom: Number(11),
               center: new google.maps.LatLng(lat, lng),
               mapTypeId: google.maps.MapTypeId.ROADMAP,
               mapTypeControl: true,
               mapTypeControlOptions:
               {

                   poistion: google.maps.ControlPosition.TOP_RIGHT
               },
               navigationControl: true,
               navigationControlOptions: {
                   style: google.maps.NavigationControlStyle.ZOOM_PAN
               },
               scaleControl: true,
               draggable: true,
               draggableCursor: 'move'
           };

           map = new google.maps.Map(document.getElementById('id_mapPanel'), options);
           zipcoder();

       } else {
           alert("Geocode was not successful for the following reason: " + status);
       }
   });
}

function zipcoder() {
try {
    var address = "85716";
    var panelDisplay = "";
    var iconName = "http://maps.google.com/mapfiles/markerA.png";

    var iconLetters = "BCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    var letter = "A";
    iconName = "http://maps.google.com/mapfiles/marker" + letter + ".png";
    panelAddresses[zipGroup] = document.getElementById('id_officeLocation').innerHTML;
    markerDisplay[zipGroup] = "<a style='font-weight: bold; color: #000000;' >" + document.getElementById("id_imageOffice").innerHTML + "</a><br/>" + document.getElementById("id_officeLoc").innerHTML;
    iconDisplay[zipGroup] = iconName;
    letter = iconLetters[zipGroup];

    zipGroup = 0;
    delayGeoCode();

} catch(err){
alert(err.message)
}
}


function delayGeoCode() {
    if (zipGroup < panelAddresses.length) {
        geoCoder.geocode({ 'address': panelAddresses[zipGroup] }, addressResolved());
    }
}

function addressResolved(results, status)
{
    return function (results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
            var marker = new google.maps.Marker({
                map: map,
                icon: iconDisplay[zipGroup],
                position: results[0].geometry.location,
            });
            (function (data, marker) {
                google.maps.event.addListener(marker, 'click', function () {
                    if (!infowindow) {
                        infowindow = new google.maps.InfoWindow();
                    }
                    infowindow.setContent(data);
                    infowindow.open(map, marker);
                });
            })(markerDisplay[zipGroup], marker);

            zipGroup = zipGroup + 1;
        } else {
            //alert("Geocode was not successful for the following reason: " + status);
        }
        window.setTimeout(delayGeoCode, 100);
    };
}




function providerBio(first, last){
    var windowFeatures = "status=0, toolbar=0, location=0, menubar=0, directories=0,scrollbars=1, left=0, height=405, width=810";

    window.open("providerPortrait.php?first=" + first + "&last=" + last, "", "width=930, height=465",windowFeatures);
}


window.onload = initializeMap();



    </script>

    </head>
<body>
    <?php 

        include("configDevelop.php");
        $result=0;
        $totalRows = 0;
        $Link = 0;
        $search_done = FALSE;
        $form_data["officeName"] = $_GET['first'];

        $Link = new mysqli(NMS_DB_HOST, NMS_DB_USER, NMS_DB_PASS, NMS_DB_NAME);
        if (mysqli_connect_errno()) {
            printf("Connect failed: %s\n", mysqli_connect_error());
            exit;
        }


        $query_where = 'WHERE ';

        if (strlen($form_data['officeName']) > 0)
            $query_where .= "OfficeName = '" . mysqli_real_escape_string($Link, trim($form_data['officeName'])) . "'";


        $query = <<<SQL
SELECT * FROM providers
$query_where
SQL;

            //echo $query;

        $result = $Link->query($query);

        if (!$result) {
            printf("Query failed: %s\n", $query);
            exit;
        }

        if($row = mysqli_fetch_array($result))
        {

            $ProvName =  $row['First']  . $row['Last'];
            $First = $row['First'];
            $Last = $row['Last'];
            $OfficeName = $row['OfficeName'];
            $Location = $row['StreetAddress'] . "<br/> " . $row['City'] . " " . $row['State']  . " " . $row['Zipcode']. "<br/> " . $row['Phone'];
            $Location2 = $row['StreetAddress'] . " " . $row['City'] . " " . $row['State']  . " " . $row['Zipcode'];
            $officeHours = $row['Hours'];
        }
        $search_done = TRUE;



    ?>

    <form id="form1">
    <?php include ("header.php"); ?>
    <div class="mainBodyProv1">
        <div class="mainBodyProv2">
            <table>
                <tr>
                    <td class="mainProviderCellLeft mainBodyCellLine">
                      <div id="id_imageOffice" class ="mainh3"><?php echo $OfficeName; ?></div>
                        <div class="mainBody3Content">
                           <div class="providerData1">
                                Location:
                            </div>
                              <div id = "id_officeLoc" class="providerData1 providerData2">
                                    <?php echo  $Location?>
                                </div> 
                                <div id=id_officeLocation class="imageTestVisible" ><?php echo  $Location2?></div>

                            <div class="providerData1">
                                Location Hours:
                            </div>
                            <div class="providerData1 providerData2">
                                    <?php echo  $officeHours?>


                            </div>
                                <br />

                            <div class="providerData1">
                        Providers:
                            </div>
                            <div >
                            <table class="providerData1 providerData2">
                                <tr>
                                </tr>
                            <?php
                                if($search_done)
                                {
                                      echo "<tr>";
                                      echo "<td class='providerCell'> <a style='text-decoration: underline' onclick='providerBio(" . "\"" .  $row['First'] . "\""  . "," . "\"" .  $row['Last'] . "\"" . ")'>" . $ProvName . "</a></td>";
                                      echo "</tr>";

                                    while($row = mysqli_fetch_array($result))
                                      {
                                      echo "<tr>";
                                      $ProvName =  $row['First']  . $row['Last'];
                                      echo "<td class='providerCell'> <a style='text-decoration: underline' onclick='providerBio(" . "\"" .  $row['First'] . "\""  . "," . "\"" .  $row['Last'] . "\"" . ")'>" . $ProvName . "</a></td>";
                                      echo "</tr>";
                                      }
                                      $result->close();
                                      $Link->close();

                                }else {
                                        echo "<tr>";
                                        echo "<td><center>No results.<center /></td>";
                                          echo "</tr>";

                                    }

                                ?>
                         </table>
                                                        </div>
                    </td>
                    <td class="mainOfficeLocCellRight">
                               <div id= "id_mapPanel" class= "mainOfficeLocContentRight" > </div>
                    </td>
                </tr>
            </table>

        </div>
    </div>

    <?php include ("footer.php"); ?>

    </form>
</body>
</html>

1 个答案:

答案 0 :(得分:1)

此:

window.onload = initializeMap();

必须是

window.onload = initializeMap;