-1

我在使用 google maps api v3 时遇到 OVER_QUERY_LIMIT 错误。我想通过地理编码从数据库中添加标记。如果我在 sql 查询中使用限制,则显示标记,如果我将限制增加到大于 10,则显示错误。

<?php
mysql_connect('localhost','root','') or die(mysql_error());
mysql_select_db('dbname') or die(mysql_error());    



$result = mysql_query("SELECT * FROM deal WHERE cityID=44 LIMIT 10") or die(mysql_error());
$count = 0;
echo mysql_num_rows($result);
$row = mysql_fetch_array($result);

?>

<script type="text/javascript">
          var geocoder;
          var map;
          //var address;
          function initialize() {


            geocoder = new google.maps.Geocoder();
            var latlng = new google.maps.LatLng(34.052234,-118.243685);
            var address = "<?php  echo $row['address']; ?>";
            //address = '3655 South Durango, Las Vegas, NV 89147';
            //alert(address);
            var myOptions = {
              zoom: 14,
              center: latlng,
              mapTypeId: google.maps.MapTypeId.ROADMAP
            }


            map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);


            <?php
                while($row = mysql_fetch_array($result)){
            ?>
            geocoder.geocode( { 'address': "<?php  echo $row['address']; ?>"}, function(results, status) {
              if (status == google.maps.GeocoderStatus.OK) {
                map.setCenter(results[0].geometry.location);
                var marker = new google.maps.Marker({
                    map: map, 
                    position: results[0].geometry.location
                });

                var contentString = '<div id="content">'+
                                      '<div id="siteNotice">'+
                                      '</div>'+
                                      "<h1 id='firstHeading' class='firstHeading'><?php  echo $row['businessName']; ?></h1>"+
                                      '<div id="bodyContent">'+
                                      "<p><?php  echo $row['longDesc']; ?></p>"+
                                      '<p>Attribution: Uluru, <a href="#">'+
                                      'Click To See</a> '+
                                      '</div>'+
                                      '</div>';
                var infowindow = new google.maps.InfoWindow({
                      content: contentString
                });
              google.maps.event.addListener(marker, 'click', function() {
                infowindow.open(map,marker);
              });
              <?php sleep(1); ?>
              } else {

                alert("Geocode was not successful for the following reason: " + status);
                //setTimeout("wait = true", 2000);
              }
            });
            <?php } ?>


          }

            google.maps.event.addDomListener(window, 'load', initialize);
        </script>
4

1 回答 1

0

免费版每天不能对超过2500 个位置进行地理编码。根据我的记忆,你还必须在两个地理编码之间等待大约 0.5 秒,所以你必须延迟你的脚本;否则你会被屏蔽。

于 2013-08-22T08:06:11.510 回答