无法显示Google Map API v3

时间:2013-06-09 03:58:35

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

更新:根据OVER_QUERY_LIMIT建议,我发现了一个可能有希望的解决方案,我将在今晚尝试。

最初我无法在我的电脑上显示Google Map API v3。相同的代码适用于亚马逊服务器。我已经搬到Rackspace,现在它没有显示。这是我正在使用的代码:

<script  type="text/javascript"
  src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBiv-nrDCYEEGzD1mk3jAfapfrBH878pqc&sensor=true">
</script>
<script>
  var geocoder;
  var map;
  function initialize() {
    geocoder = new google.maps.Geocoder();
    var phpAddressInit = "<?php echo $mapAddress ?>";
    //document.write("phpAddressInit: " + phpAddressInit);
    //var latlng = new google.maps.LatLng(-34.397, 150.644);
    var latlng = new google.maps.LatLng(33.5750, -117.7256);
    var mapOptions = {
      zoom: 10,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }
    map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
    geocoder.geocode( { 'address': phpAddressInit}, function(results, status) {
      //alert("---address3: " + phpAddressInit);
      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
        });
      } else {
        alert('Geocode was not successful for the following reason: ' + status);
      }
    });
  }

  function codeAddress(control,ctrlAddress) {
    //alert("---in codeAddress; " + "control: " + control
    //      + "ctrlAddress: " + ctrlAddress);
    //var address = document.getElementById('address').value;
    //aws.push
    var address;
    if ( control == 1 )
    {
        address = document.getElementById('address').value;
    }
    else
    {
        address = ctrlAddress;
    }

    geocoder = new google.maps.Geocoder();
      //alert("---address1: " + address);
    geocoder.geocode( { 'address': address}, function(results, status) {
      //alert("---address2: " + address);
      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
        });
      } else {
        alert('Geocode was not successful for the following reason: ' + status);
      }
    });
  }
</script>

...

我用谷歌搜索了几个小时,尝试了几个不同的例子,但它不会显示。我错过了什么?

1 个答案:

答案 0 :(得分:0)

Seb P让我意识到它现在正在运作。谢谢,它现在正在运作。

仍然使用不起作用的原始代码,所以我无法自信地说问题已得到修复。查看与OVER_QUERY_LIMIT相关联的链接,Rackspace似乎将用户组合在一起使用相同的IP导致此错误。

这些都没有得到证实,但似乎与我所看到的相符。如果有人能够更多地了解这一点,那就可以避免这个问题。

相关问题