Reverse geo

13 views
Skip to first unread message

Jeroen Nicolai

unread,
Nov 3, 2011, 5:00:57 AM11/3/11
to google-map...@googlegroups.com
Hi there,

First off thank you for reading.

I got a question regarding breaking down the address that google returns.
It now shows the full address but I would like to extract the city name only.

Thanks again.

Jeroen

--- Code I use --- Part of this example -> http://wptuts.net/newgeotest.html

    $(function() {

    $("#auto-address").autocomplete({

      //This bit uses the geocoder to fetch address values

      source: function(request, response) {

        geocoder.geocode( {'address': request.term }, function(results, status) {

          response($.map(results, function(item) {

            return {

              label:  item.formatted_address,

              value: item.formatted_address,

              latitude: item.geometry.location.lat(),

              longitude: item.geometry.location.lng()

            }

          }));

        })

      },

      //This bit is executed upon selection of an address

      select: function(event, ui) {



        var location = new google.maps.LatLng(ui.item.latitude, ui.item.longitude);

        marker.setPosition(location);

searchedLocation = marker.getPosition();

        map.setCenter(location);

updateMarkerPosition(location);

geocodePosition(location);

$("#address").text(location);

$("#formattedAddress").text('Address search result:');

        $("#info").text(searchedLocation);

      }

    });

  });

JKurtock

unread,
Nov 3, 2011, 9:28:29 PM11/3/11
to Google Maps JavaScript API v3
Reply all
Reply to author
Forward
0 new messages