Google 地理编码器在一个页面上抛出 MissingKeyMapError 而不是另一个

Google geocoder throwing MissingKeyMapError on one page but not another

我有两个网站,它们做的事情本质上是一样的——获取地址并将它们放入数据库中。两个网站似乎都有相同的代码。但是一页会抛出 MissingKeyMapError 而另一页不会。我认为两者之间没有太大区别。有人可以帮忙吗?

第一个网站jquery:

var latlong = [];
//addresses is a long array made up of addresses such as
//"1056 BRUSHTON AVE, Pittsburgh"
var geocoder = new google.maps.Geocoder();
$(document).ready(function() {
    var count = 23963; //the record number in the database
    setInterval(function(){
        if (addresses.length > 0) {
            for (var i=0; i< 11; i++) { //limit of 11 at a time so don't overwhelm API
                var address = addresses[i];
                count++;
                locate(address, count);
            }
            addresses.splice(0, 11); //go to the next 11 addresses
        } else {
            clearInterval();
        }
    }, 30000);
});

function locate(address, count) {
    geocoder.geocode( { 'address': address}, function(results, status) {

      if (status == google.maps.GeocoderStatus.OK) {
        var lat = results[0].geometry.location.lat();
        var lng = results[0].geometry.location.lng();
        $.post('php/push_latlng.php', {address: address, lat: lat, lng: lng, count:count },function(){
               //put it in the database
        });
      }

    }); 
}

第二个网站jquery:

var latlong = [];
var geocoder = new google.maps.Geocoder();
$(document).ready(function() {
    $.post('php/get_address.php', function(addresses){
    //get addresses out of the database and turn them into json             
    var obj = jQuery.parseJSON( addresses );
            //addresses are in the format "1800 Mulberry St, Scranton, PA"
            for (var i = 0; i< 2; i++) { //arbitrary small number
                var medID = obj[i].medID;
                var address = obj[i].address;
                locate(address, medID);
            }
    });

});
function locate(address, medID) {
    geocoder.geocode( { 'address': address}, function(results, status) {
        });
}

第二页报错: js?sensor=false:32 Google 地图 API 错误:MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error

有人知道我做错了什么吗?

现在需要密钥。 2016 年 6 月 22 日之前在没有密钥的情况下处于活动状态的站点是 "grandfathered",并且将在没有密钥的情况下继续工作(至少现在是这样)。新站点需要密钥。