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: Klaus, FourthWorld, heatherlaine, kevinmiller

Auto Detect Location For Weather

Postby 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..
proloy
 
Posts: 11
Joined: Thu Aug 17, 2017 9:07 am

Re: Auto Detect Location For Weather

Postby 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
Klaus
 
Posts: 9495
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany

Re: Auto Detect Location For Weather

Postby 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.
proloy
 
Posts: 11
Joined: Thu Aug 17, 2017 9:07 am

Re: Auto Detect Location For Weather

Postby 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 livecode blog: http://livecodeitalia.blogspot.it
To post code use this: http://tinyurl.com/ogp6d5w
MaxV
 
Posts: 1287
Joined: Tue May 28, 2013 2:20 pm
Location: Italy


Return to Getting Started with LiveCode - Complete Beginners

Who is online

Users browsing this forum: No registered users and 5 guests

cron