0

Hello fellow androiders, it's been a while!

I need some help with creating dates from coordinates.

I'm using google maps and when the user places the camera over a geographical area I want to display it's local time.

gMap.setOnCameraIdleListener {} can provide me with a CameraPosition, which contains a LatLng.
I is there a way to convert it into a timezone without using an additional API.

Any thoughts?

Edit: The question is for Android especially.

Joel Broström
  • 3,530
  • 1
  • 34
  • 61
  • https://developers.google.com/maps/documentation/timezone/start – assylias Apr 18 '19 at 14:15
  • @assylias I think your post is more general since it lists web scripts and python code. I want it specifically for android. – Joel Broström Apr 18 '19 at 14:23
  • It lists a number of REST calls that can give you the answer. I don't think you can easily do it through code only. AFAIK, the Java API only has timezone names and offsets, but not the geographic area in which they are used. Say you find a GPS point in the US, how will you know which timezone it is in? In the end, I think you will probably have to rely on a third party provider. – assylias Apr 18 '19 at 14:28
  • All I would need is an index of the different time zones. Most areas follow the one hour increment logic, and the rest would have to be stored as exception polygons. I can calculate the position of the sun with 0.08 degree accuracy for the next 100 years locally (which is what I'm doing and now want to show the data in local time). I guess the sun is more consistent than humans :) I realise I'm wrong, since if it were that simple some one would have done it as a open source-library already. – Joel Broström Apr 18 '19 at 14:46
  • Timezones are far from being simple shapes. See this map for example and look at the delimitation of timezones in the US and Canada, or in Russia: https://www.timetemperature.com/time-zone-maps/large-world-time-zone-map.shtml – assylias Apr 18 '19 at 14:56
  • So if you want something 100% robust, it's going to be hard to do manually. If you don't mind occasional errors, you can programmatically find the country of the GPS coordinates and then the timezone(s) of that country as a starting point. – assylias Apr 18 '19 at 14:59

0 Answers0