Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/428.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何给一个城市贴上时间戳_Javascript_Google Maps - Fatal编程技术网

Javascript 如何给一个城市贴上时间戳

Javascript 如何给一个城市贴上时间戳,javascript,google-maps,Javascript,Google Maps,我可以使用下面的代码找到当前位置的时间戳 navigator.geolocation.getCurrentPosition(函数(位置){ 但是,有可能找到地址或城市的时间戳吗?我可以找到城市的经纬度,但找不到时间戳 var geocoder = new google.maps.Geocoder(); geocoder.geocode({ 'address': "chennai" }, function (results, status) { if (

我可以使用下面的代码找到当前位置的时间戳

navigator.geolocation.getCurrentPosition(函数(位置){

但是,有可能找到地址或城市的时间戳吗?我可以找到城市的经纬度,但找不到时间戳

var geocoder = new google.maps.Geocoder();

        geocoder.geocode({ 'address': "chennai" }, function (results, status) {

            if (status == google.maps.GeocoderStatus.OK) {

               var position= new google.maps.LatLng(results[0].geometry.location.lat(),             
                           results[0].geometry.location.lng())

            }
        });
如何使用纬度和经度值查找地址的时间戳


提前感谢

谷歌没有API,您可以在请求中设置纬度和经度作为参数,并在响应中获取时间戳。谷歌提供了时区API,但它也将时间戳作为输入参数,这在您的情况下没有用

这里最好的选择是使用第三方API,该API将输入参数作为纬度和经度,并以时间戳的形式给出响应。您可以使用该结果生成一个变量,并将其显示在地图的信息窗口中。这里是一个用于XML的API和一个用于JSON的API。

您可以请求
var geocoder = new google.maps.Geocoder();

        geocoder.geocode({ 'address': "chennai" }, function (results, status) {

            if (status == google.maps.GeocoderStatus.OK) {

               var position= new google.maps.LatLng(results[0].geometry.location.lat(),             
                           results[0].geometry.location.lng())

            }
        });