V
V
VPVPVP2020-01-03 18:14:28
Google Maps
VPVPVP, 2020-01-03 18:14:28

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)


Apparently, something may have changed in Google api, since everything worked correctly, now in the console it gives out like this
Uncaught TypeError: Cannot read property 'geometry' of undefined
at Object.complete


Everything worked correctly a year ago, now this is in the console. I already changed the google api key, it did not help

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question