Note: you will have errors if you don’t add the following
var geocoder= new google.maps.Geocoder();
Like Below
var geocoder= new google.maps.Geocoder();
// get the address using the geocoder
geocoder.geocode({ 'latLng' : latlng }, function( results, status ){