-
-
Save dody87/12897208a72147c2319c0bf7cbc200ad 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
_getCityState = function(resp){ | |
var res = ''; | |
if (resp.status == 'OK') { | |
if (resp.results[1]) { | |
var city=false,state=false; | |
for (var i = 0; i < resp.results.length; i++) { | |
if ((!city || !state) && resp.results[i].types[0] === "locality") { | |
city = resp.results[i].address_components[0].short_name, | |
state = resp.results[i].address_components[2].short_name; | |
res = city + ", " + state; | |
} | |
} | |
} | |
} | |
}; | |
rickyriccs
commented
Feb 13, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment