Google maps geolocation address

I am trying to use google maps plugin and geolocation to give current users address when they hit the use my location button but I can't figure out what I need to do to get it to output an address instead of a latitude and longitude.
1 person has
this question
+1
Reply
  • Hunter,

    Provided you are using jQuery - I have a plugin that does exactly that. Has a sample UI and code that does the calculation of address given a lat / lng - you can use the code and replace the UI components - with data from your location service.

    If you'd like it - email me @ bruce.Stuart@the-software-studio.com

    Best,

    Bruce
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited

  • Minus the plugin - here is the code that does the work - you can replace the inputs and outputs - to suite your own situation - in order to use it without the UI that's imbedded / assumed in the code below:

    function fGeoCodeMe() {
    var geocoder = new google.maps.Geocoder;
    var nLat = Number( Appery('inputLat').val() ) ;
    var nLng = Number( Appery('inputLng').val() ) ;
    var oLatLng = {
    lat: nLat,
    lng: nLng
    };
    geocoder.geocode({
    'location': oLatLng
    }, function(results, status) {
    Appery('labelGetLatLngStatus').text( status );
    if (status === 'OK') {
    if (results[1]) {
    Appery('labelComputedAddress').text( results[1].formatted_address ) ;
    } else {
    alert('No results found');
    }
    } else {
    alert('Geocoder failed due to: ' + status);
    }
    });
    }
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. indifferent, undecided, unconcerned sad, anxious, confused, frustrated kidding, amused, unsure, silly happy, confident, thankful, excited