【问题标题】:google map v3 OVER_QUERY_LIMIT - Geocoding with PHP MYSQLgoogle map v3 OVER_QUERY_LIMIT - 使用 PHP MYSQL 进行地理编码
【发布时间】:2013-08-20 09:17:13
【问题描述】:

我在使用 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>

【问题讨论】:

标签: php mysql google-maps-api-3


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-01
    • 1970-01-01
    • 2013-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多