I have two websites that do essentially the same thing - take addresses and put them in a database. Both websites seem to have the same code. But one page throws the MissingKeyMapError and the other doesn't. I don't see much difference between the two. Can anyone help please?
First website 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
});
}
});
}
Second website 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) {
});
}
The second page throws this error: js?sensor=false:32 Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error
Anyone know what I'm doing wrong?