-
-
Save buralex/f17bcbf7471b4d4de357dfe30f106e04 to your computer and use it in GitHub Desktop.
Get only city and state from Google Maps API Reverse Geocoder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for (var ac = 0; ac < results[0].address_components.length; ac++) { | |
| var component = results[0].address_components[ac]; | |
| switch(component.types[0]) { | |
| case 'locality': | |
| storableLocation.city = component.long_name; | |
| break; | |
| case 'administrative_area_level_1': | |
| storableLocation.state = component.short_name; | |
| break; | |
| case 'country': | |
| storableLocation.country = component.long_name; | |
| storableLocation.registered_country_iso_code = component.short_name; | |
| break; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment