Created
August 11, 2017 20:25
-
-
Save csexton/5bd8d7634e51c026f3d16507bcdd51c2 to your computer and use it in GitHub Desktop.
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
get_tz = ()-> | |
lat = $('input[name=lat]').val() | |
lng = $('input[name=lng]').val() | |
time = Math.round((new Date().getTime())/1000) | |
$.ajax( | |
url:"https://maps.googleapis.com/maps/api/timezone/json?location=#{lat},#{lng}×tamp=#{time}&sensor=false", | |
).done((response) -> | |
if(response.timeZoneId != null) | |
console.log(response) | |
alert(response.timeZoneId) | |
) | |
defer_tz_updater = null | |
defer_get_tz = ()-> | |
# Defer the change incase this gets called multiple times quickly | |
clearTimeout(defer_tz_updater) | |
defer_tz_updater = setTimeout(get_tz,500) | |
$('input[name=lat]').change (event)-> | |
defer_get_tz() | |
$('input[name=lng]').change (event)-> | |
defer_get_tz() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment