Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getTown(latitude,longitude){
- // Define Geocoding
- var geocoder = new google.maps.Geocoder();
- // Using the longitude / latitude get address details
- var latlng = new google.maps.LatLng(latitude,longitude);
- geocoder.geocode({'latLng': latlng}, function(results, status){
- // If response ok then get details
- if (status == google.maps.GeocoderStatus.OK) {
- var town = results[1].address_components[1].long_name;
- return town; // Returns Norwich when alerted using the e.g below.
- }
- });
- }
- getTown(52.649334,1.288052);
- var theTown = null;
- function getTown(latitude,longitude){
- // Define Geocoding
- var geocoder = new google.maps.Geocoder();
- // Using the longitude / latitude get address details
- var latlng = new google.maps.LatLng(latitude,longitude);
- geocoder.geocode({'latLng': latlng}, function(results, status){
- // If response ok then get details
- if (status == google.maps.GeocoderStatus.OK) {
- var town = results[1].address_components[1].long_name;
- theTown = town; // Returns Norwich when alerted using the e.g below.
- }
- });
- }
Add Comment
Please, Sign In to add comment