Skip to content

Instantly share code, notes, and snippets.

View dody87's full-sized avatar

Dody dody87

View GitHub Profile
@dody87
dody87 / citystategeo.js
Last active February 13, 2020 17:55 — forked from danasilver/citystategeo.js
Get only city and state from Google Maps API Reverse Geocoder
_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;