Created
April 24, 2014 00:15
-
-
Save amitittyerah/11237047 to your computer and use it in GitHub Desktop.
Get bounds from the Google Maps Autocomplete response
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
function get_bounds(gmaps_autocomplete_response) { | |
var lats = false, longs = false; | |
$.each(gmaps_autocomplete_response.geometry.viewport, function () { | |
if (!lats || !longs) { | |
var x,y = false; | |
var ref = false; | |
$.each(this, function () { | |
if (!x || !y) { | |
if (!x) x = this; | |
else y = this; | |
} else { | |
ref = {x: x, y: y}; | |
} | |
}); | |
if (!lats) lats = ref; | |
else longs = ref; | |
} | |
}); | |
return {latitudes: lats, longitudes: longs}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment