Php 如何在谷歌地图api中逐个获取标记?

Php 如何在谷歌地图api中逐个获取标记?,php,jquery,google-maps,Php,Jquery,Google Maps,我正在使用google map API显示50多个位置的标记,但我面临一个延迟时间的问题,在地图上加载标记需要花费很多时间 这是我的密码 <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <title>Google Maps</title> <script type="text/javascr

我正在使用google map API显示50多个位置的标记,但我面临一个延迟时间的问题,在地图上加载标记需要花费很多时间

这是我的密码

<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Google Maps</title>
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> 
  </head>
  <body>


    <div id="map" style="width:600px;height:400px;"></div>
    <div id="messages"></div>

    <script type="text/javascript">
    //<![CDATA[


    // delay between geocode requests - at the time of writing, 100 miliseconds seems to work well
    var delay = 100;


      // ====== Create map objects ======
      var infowindow = new google.maps.InfoWindow();
      var latlng = new google.maps.LatLng(-34.397, 150.644);
      var mapOptions = {
        zoom: 8,
        center: latlng,
        mapTypeId: google.maps.MapTypeId.ROADMAP
      }
      var geo = new google.maps.Geocoder(); 
      var map = new google.maps.Map(document.getElementById("map"), mapOptions);
      var bounds = new google.maps.LatLngBounds();

      // ====== Geocoding ======
      function getAddress(search, next) {
        geo.geocode({address:search}, function (results,status)
          { 
            // If that was successful
            if (status == google.maps.GeocoderStatus.OK) {
              // Lets assume that the first marker is the one we want
              var p = results[0].geometry.location;
              var lat=p.lat();
              var lng=p.lng();
              // Output the data
                var msg = 'address="' + search + '" lat=' +lat+ ' lng=' +lng+ '(delay='+delay+'ms)<br>';
                document.getElementById("messages").innerHTML += msg;
              // Create a marker
              createMarker(search,lat,lng);
            }
            // ====== Decode the error status ======
            else {
              // === if we were sending the requests to fast, try this one again and increase the delay
              if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT) {
                nextAddress--;
                delay++;
              } else {
                var reason="Code "+status;
                var msg = 'address="' + search + '" error=' +reason+ '(delay='+delay+'ms)<br>';
                document.getElementById("messages").innerHTML += msg;
              }   
            }
            next();
          }
        );
      }

     // ======= Function to create a marker
     function createMarker(add,lat,lng) {
       var contentString = add;
       var marker = new google.maps.Marker({
         position: new google.maps.LatLng(lat,lng),
         map: map,
         zIndex: Math.round(latlng.lat()*-100000)<<5
       });

      google.maps.event.addListener(marker, 'click', function() {
         infowindow.setContent(contentString); 
         infowindow.open(map,marker);
       });

       bounds.extend(marker.position);

     }

      // ======= An array of locations that we want to Geocode ========
      var addresses = [
               '2780 Race Track Road Jacksonville, FL ,32259 USA',
'2770 Race Track Road Jacksonville, FL ,32259 usa',
'13700 Fario Road Jacksonville, FL ,32224 usa',
'10675-1 Atlantic Blvd Jacksonville, FL ,32225 usa',
'9052 New Kings Rd Jacksonville, FL ,32219 usa',
'12608 San Jose Blvd Jacksonville, FL ,32223 usa',
'5027-1 Sunbeam Rd Jacksonville, FL ,32257 usa',
'322 State Road 16 St Augustine, FL ,32084 usa',
'5850 Lenox Avenue Jacksonville, FL ,32205 usa',
'232 SR 16 St Augustine, FL ,32084 usa',
'1771 State Road 1-3 Jacksonville, FL ,32259 usa',
'1471 Monument Road Jacksonville, FL ,32225 usa',
'1625 Old Moultrie Road St Augustine, FL ,32084 usa',
'2825 Mayport Rd Atlantic Beach, FL ,32233 usa',
'10200 Beach Blvd Jacksonville, FL ,32246 usa',
'8041 N Main Street Jacksonville, FL ,32208 usa',
'500 State Road 13 Jacksonville, FL ,32259 usa',
'5748 Arlington Road Jacksonville, FL ,32211 usa',
'490 Levy Road Atlantic Beach, FL ,32233 usa',
'14476 Duval Place W Suite 204 Jacksonville, FL ,32218 usa',
'4671 Highway Avenue Jacksonville, FL ,32254 usa',
'4381 County Road 218 Middleburg, FL ,32068 usa',

      ];

      // ======= Global variable to remind us what to do next
      var nextAddress = 0;

      // ======= Function to call the next Geocode operation when the reply comes back

      function theNext() {
        if (nextAddress < addresses.length) {
          setTimeout('getAddress("'+addresses[nextAddress]+'",theNext)', delay);
          nextAddress++;
        } else {
          // We're done. Show map bounds
          map.fitBounds(bounds);
        }
      }

      // ======= Call that function for the first time =======
      theNext();

    // This Javascript is based on code provided by the
    // Community Church Javascript Team
    // http://www.bisphamchurch.org.uk/   
    // http://econym.org.uk/gmap/

    //]]>
    </script>
  </body>

</html>

谷歌地图

//如果你的地址是固定的,为什么不使用坐标呢?我猜造成延迟的原因是地理编码,而不是从数据库中获取地址的标记。在上面的代码中,我只是展示了我正在使用的逻辑…然后问题变成了“为什么你不能将坐标和地址一起保存在数据库中?”?事实上,我是新来的..请分享代码或逻辑,我可以通过这些代码或逻辑了解如何显示带有存储地址和坐标的标记..我应该使用哪些坐标?这是从谷歌使用api加载的…还是我应该创建自定义函数来查找坐标?