언어 설정

Menu
Sites
Language
Watchface with sunrise/sunset

Hello - I've built a watchface for my gear s2 and would like to add sunrise and sunset information to it.  I understand this data is available in the JSON response from the OpenWeatherMap API for which I have an API key.  

My question, being very new to tizen studio writing javascript for watch faces, is how can I get the watch's current zip code (or city name or city id) in order to call the OpenWeatherMap API?

Here's the sample JSON which shows the sunrise and sunset info:

{"coord":{"lon":145.77,"lat":-16.92},"weather":[{"id":802,"main":"Clouds","description":"scattered clouds","icon":"03n"}],"base":"stations","main":{"temp":300.15,"pressure":1007,"humidity":74,"temp_min":300.15,"temp_max":300.15},"visibility":10000,"wind":{"speed":3.6,"deg":160},"clouds":{"all":40},"dt":1485790200,"sys":{"type":1,"id":8166,"message":0.2064,"country":"AU","sunrise":1485720272,"sunset":1485766550},"id":2172797,"name":"Cairns","cod":200}

 

Thanks in advance!  Any sample JS code would be very helpful - thanks!!

답변 바로가기

Responses

1 댓글
Mark as answer
Armaan-Ul- Islam

You can use GeoLocation API to detect current location Information.

Geolocation API Specification
 

In Addition, Here are some relevant Tizen Web Code Snippets :

Get watch current location in web application

Get current location in web application