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.
$(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);
}
});
});