Auto Detect Location For Weather

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
proloy
Posts: 19
Joined: Thu Aug 17, 2017 9:07 am

Auto Detect Location For Weather

Post by proloy » Thu Sep 14, 2017 5:23 am

Hello,
Again I am here with new quarry! Last time “Jilm” solved my problem.
I like to add Auto Detect Location and put latitude, longitude in Dark Sky API. This is a desktop client for casparCG.
My Button code is below:

Code: Select all

 on mouseUp
   put the text of fld "city" into tCityName
   put the text of fld "country" into tCountry
   put "?units=si" into si
   
   
put "[https]://api.darksky.[net]/forecast/f75094a5a6e929acb6e7274f363dadab/23.727785,90.413495"&si into tURL
put URL tURL into tRawJSON
put textDecode(tRawJSON,"UTF8") into fld "weatherdata"
put arrayFromJson(tRawJSON) into tArray

put tArray["currently"]["summary"] into fld "Status"
put tArray["currently"]["temperature"] into fld "Temp"
put tArray["currently"]["apparentTemperature"] into fld "RealFeels"
put tArray["currently"]["windSpeed"] into fld "WindSpeed"
put tArray["currently"]["humidity"] into fld "Humidity"

end mouseUp
As a fresher I always follow and read forum senior members post/suggestions. I have search a lot and google it, but no luck.

Please advice..

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Auto Detect Location For Weather

Post by Klaus » Thu Sep 14, 2017 12:14 pm

Hi proloy,

I am missing your question! :D

OK, use the correct syntax and it will work fine:
...
put URL tURL into tRawJSON
put textDecode(tRawJSON,"UTF8") into fld "weatherdata"
## put arrayFromJson(tRawJSON) into tArray
put JSONtoArray(tRawJSON) into tArray
...
Hint: the dictionary is your friend!


Best

Klaus

proloy
Posts: 19
Joined: Thu Aug 17, 2017 9:07 am

Re: Auto Detect Location For Weather

Post by proloy » Sat Sep 16, 2017 3:53 am

@klaus, thanks for your reply.
Actually, i like to know: is there any way to get "Auto detect Current location, latitude & longitude data" without GPS. i am going to use this data in darksky API (latitude, longitude) position.

I already share my weather Button code, as you can understand what i want to do :)

Thanks.

MaxV
Posts: 1579
Joined: Tue May 28, 2013 2:20 pm
Location: Italy
Contact:

Re: Auto Detect Location For Weather

Post by MaxV » Thu Sep 21, 2017 1:02 pm

You can try: http://freegeoip.net or https://www.geoiptool.com/
but I don't know how much is accurate.

Best regards
Max
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”