我有两个基本相同的网站 - 获取地址并将它们放在数据库中。两个网站似乎都有相同的代码。但是一个页面抛出了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 Maps API错误:MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error
任何人都知道我做错了什么?
答案 0 :(得分:4)
现在需要密钥。 2016年6月22日之前没有钥匙的活动网站已经过了#34;#34;并将继续工作没有钥匙(至少现在)。新网站需要密钥。