Answer the question
In order to leave comments, you need to log in
Uncaught TypeError: Cannot read property 'geometry' of undefined in google places?
In general, I deployed the old site "starry sky map generator"
It has an input that works through google autocomplete (google places)
According to the idea, when you enter some city or place, json collects latitude and longitude and thus twists the "starry sky map"
This piece of code looks like this.
function getStarmapDetails(id, atitle){
var sessionToken = getSessionToken();
$.ajax({
url: 'https://maps.googleapis.com/maps/api/geocode/json?place_id=' + id + '&key=тутмойключгуглапи'+'&sessiontoken=' + sessionToken,
method: 'get',
dataType: 'json',
beforeSend: function() {
// $b.addClass('is-searching');//?
//alert('beforeSend');
},
complete: function(data) {
if(data){
//alert('data='+data);
data = data.responseJSON.results[0];
//console.log('atitle='+atitle);
//console.log('data='+data);
//var smtitle = data.address_components[0].long_name;
var smtitle = atitle;
var smlat = data.geometry.location.lat;
var smlng = data.geometry.location.lng;
console.log('smtitle='+smtitle+';'+'smlat='+smlat+';'+'smlng='+smlng+';'+'id='+id+';');
//alert('smtitle='+smtitle+';'+'smlat='+smlat+';'+'smlng='+smlng+';'+'id='+id+';');
//updateWithTimezone(['title','lat','lng'],[smtitle,smlat,smlng]);
updateWithTimezone({
'title': smtitle,
'lat': smlat,
'lng': smlng
});
}//if(data)
}
});//$.ajax
//alert('after ajax');
eraseCookie('sessionToken');
}//function getStarmapDetails(id, atitle)
Uncaught TypeError: Cannot read property 'geometry' of undefined
at Object.complete
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question