C
C
Cesare Borgia2014-04-17 19:06:26
Google Maps
Cesare Borgia, 2014-04-17 19:06:26

How to get results variable outside geocode function? Google Maps API

Good day!
There is such code Google M... geocoding example .
Only within this area can I get results[0].geometry.location

geocoder.geocode( { 'address': address}, function(results, status) {
    if (status == google.maps.GeocoderStatus.OK) {
      map.setCenter(results[0].geometry.location);
      var marker = new google.maps.Marker({
          map: map,
          position: results[0].geometry.location
      });
    } else {
      alert('Geocode was not successful for the following reason: ' + status);
    }

And I need this variable outside the function. I tried to declare it outside and inside the function through var, and through window, it does not lend itself in any way. I was able to pull it out through cookies, but to use it you have to reload the page, and this is not the same.
Perhaps someone has come across this issue before.

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