我可以使用google maps api v3来获取位置的时区吗?

11 google-maps-api-3

是否可以使用google maps api来获取时区?我已经在使用它的api进行地理编码和地图显示,我还想添加时区.但我在文档中找不到任何内容.

有任何想法吗?链接?

小智 15

您可以使用Timezone API.

例如(使用jQuery):

$.ajax({
   url:"https://maps.googleapis.com/maps/api/timezone/json?location=6.123123,106.213144&timestamp="+(Math.round((new Date().getTime())/1000)).toString(),
})
.done(function(response){
   if(response.data.timeZoneId != null){
     //do something
   }
});
Run Code Online (Sandbox Code Playgroud)

您可以从GoogleMaps API获取位置坐标(纬度/经度).

请注意,您需要使用特定密钥才能使用此API.