var geocoder = new google.maps.Geocoder();
geocoder.geocode({\'latLng\': foundLoc}, function(results, status) {
if (status == google.maps
This seems to work for me so far...
readCityAndStateFromResult: (data) ->
displayName = []
for component in data[0].address_components
if component.types and component.types.length
switch true
when 'locality' in component.types
displayName.push component.long_name
when 'administrative_area_level_1' in component.types or 'administrative_area_level_2' in component.types
displayName.push component.short_name
return displayName.join ', ' if displayName.length
return null
Why do you parse formatted_address
?
There are the address_components, you can walk through them and look for the ones with
"types": [ "administrative_area_level_1", "political" ]// the state
"types" : [ "locality", "political" ]//the city
Here's an example: http://jsfiddle.net/doktormolle/QWPCL/