var geocoder = new google.maps.Geocoder();
var address = document.getElementById('sub_id').value;
var address1=document.getElementById('sub').value;
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
console.log('Inside status');
var latitude = results[0].geometry.location.lat();
longitude = results[0].geometry.location.lng();
}
});
console.log(latitude);
When I am trying to print the above latitude and longitude on outside the function, the value is undefined.
How can I solve this issue?