Thread: GPS Based Weather Widgets
-
01-09-2012, 03:12 PM #1
GPS Based Weather Widgets
Hey Guys,
I been thinking about how to make Weather Widgets for themes "Live"(Based on your GPS Lat/Long). I found code out there from this website javascript - Access iPhone GPS coordinates - Stack Overflow
Code
Would there be any way to get the Var to use your GPS Location to fetch your location code from Yahoo! Weather to make weather widgets like the one I am using(Equix HD) use this?navigator.geolocation.getCurrentPosition( function(loc){
var lat = loc.coords.latitude;
var lon = loc.coords.longitude;
doSomethingWith( lat, lon ); // your function
});
From my other post in the Equix thread
But, could you make the code Var code in equix say fetch GPS location from device(iphone) fetch Location code Yahoo! WeatherLast edited by tntgo; 01-09-2012 at 03:29 PM.
-
-
01-09-2012, 05:36 PM #2
I just want to say, I'm just getting into coding and learning, its taking me time to learn. If there is anyone who knows how to do this don't feel afraid to step on my toes and say so and let us all know how you did it. I though am more a concept person(more visual based).
If it ain't broke, you haven't tried hard enough
-
01-09-2012, 06:40 PM #3
I have heard of reverse geocoding, is that what needs to be part of the html code to pull the gps location for the widget? I'm think what would have to happen is that Widget would have to ask for the gps lat/long of the device, then it would somehow have to mix that with overlaying the location code that it parsed from Yahoo! Weather and spit that out in the form of the Town and temp and conditions like the equix widgets do.
If it ain't broke, you haven't tried hard enough
-
01-10-2012, 11:15 AM #4
Ok, so maybe I'm on the right track?
This is my combined code so far, original code is from Equix theme
I used the code from here for the GPS function// The location field should be a relatively machine-legible string
// if using the default, Apple/AccuWeather parser (originally from Leopard's Weather.wdgt)
var locale = "navigator.geolocation.getCurrentPosition( function(loc){
var lat = loc.coords.latitude;
var lon = loc.coords.longitude;
api.geonames.org/findNearbyPostalCodes?;postalcode,country, radius (1.609344 Km), maxRows (default = 1)( lat, lon ); //
});" //e.g. 'Defiance, Ohio'|'Moscow, Russia'|'Ledyard, AT'|'London, UK'
javascript - Access iPhone GPS coordinates - Stack Overflow
I used the code from here for the Postal code lookup function(and I edited the radius for 1 mile/1.609344 Kilometers) + I edited the field of postal code lookup rows from 5 to 1
GeoNames Web Service Documentation
I have no idea if I have the code setup right so far? Somehow still need to figure out how to use what postal code it looks up to parse the postal code using the gps function and the Geonames lookup system from the Yahoo! Extended Weather Forecast.
Like I said, I have no idea if I have the code setup right(since I'm not very good at html coding). If anyone could let me know if I have it setup right + if someone knows how to parse the postal code field from the extended weather forecast on Yahoo! Weather
Will that even work since the GPS function is java code and not html code. Is there something I need to change to make into HTML code?Last edited by tntgo; 01-10-2012 at 11:41 AM.
If it ain't broke, you haven't tried hard enough
-
01-10-2012, 12:02 PM #5Livin the iPhone Life
- Join Date
- Mar 2011
- Location
- Winchester, UK
- Posts
- 1,680
- Thanks
- 1,307
- Thanked 951 Times in 523 Posts
It might be worth giving Ian Nicoll and Dacal a PM. They are the undisputed champions of the weather widget. <br><br>Don't give up though!!!

-
The Following User Says Thank You to KraXik For This Useful Post:
tntgo (01-10-2012)
-
01-10-2012, 12:04 PM #6
I will do that, do you think its okay that I am using the code from these websites, since its just posted free on the internet I thought it would be ok to use?
Also, how I find users and should we make this thread a sticky so it doesn't get crushed by all the other threads if no one posts in it?Last edited by tntgo; 01-10-2012 at 12:10 PM.
If it ain't broke, you haven't tried hard enough
-
01-10-2012, 12:16 PM #7Livin the iPhone Life
- Join Date
- Mar 2011
- Location
- Winchester, UK
- Posts
- 1,680
- Thanks
- 1,307
- Thanked 951 Times in 523 Posts
<br><br>Just a note of credit is usually fine when borrowing free stuff on te Internet.<br><br>Search is kaput right now so the easiest way is just to use google. Maybe talk to a mod about sticky-ing the post. Pretty much every theme has a weather widget an everyone has to SSH their own code. Not having to do this would be amazing!<br><br>

-
The Following User Says Thank You to KraXik For This Useful Post:
tntgo (01-10-2012)
-
01-10-2012, 12:56 PM #8
I sent Ian Nicoll and Dacal PM's hopefully they will respond
If one of the mods can sticky this thread, I would appreciate it.Last edited by tntgo; 01-10-2012 at 01:26 PM.
If it ain't broke, you haven't tried hard enough
-
01-30-2012, 01:21 PM #9
Hello Friends,
I am very new to iPhone skinning/themes. And have been working for a few days to get the current location on the lockscreen that can be used by weather widget to display local weather without altering/entering location code. I have used similar geolocation javascript code in a HTML lock screen. But the code does not work on either Lockscreen.html or wallpaper.html. But it works fine when these files are launched in "iFile" and I can see the latitude and longitude displayed.
The idea here is to get the WOEID for that location using latitude and longitude.
Then I found out that this WOEID is also stored in the file "//var/mobile/Library/Preferences/com.apple.weather.plist" which is used by weather app.
Local Weather info is stored under "<key>LocalWeather</key>" and WOEID for the current location is stored after this string. Search for the string <key>Woeid</key> after <key>LocalWeather</key>. This will give you the WOEID for that current location.
Is there any way we can read this WOEID from "//var/mobile/Library/Preferences/com.apple.weather.plist" on the HTML lockscreen?
Appreciate if I can get a help on this.
Thanks.
-
01-30-2012, 01:29 PM #10The Infamous Modder
- Join Date
- Jun 2011
- Posts
- 1,699
- Thanks
- 136
- Thanked 1,707 Times in 798 Posts
- Blog Entries
- 1
Based on this
1. Battery Drain
2. Would constantly be refreshing itself inturn leading to no 1.
-
01-30-2012, 01:38 PM #11
You may set a refresh interval for this as all other HTML lockscreens do. But is there any way we can read this WOEID from "//var/mobile/Library/Preferences/com.apple.weather.plist" on the HTML lockscreen?
-
01-30-2012, 02:00 PM #12The Infamous Modder
- Join Date
- Jun 2011
- Posts
- 1,699
- Thanks
- 136
- Thanked 1,707 Times in 798 Posts
- Blog Entries
- 1
-
01-30-2012, 02:08 PM #13Livin the iPhone Life
- Join Date
- Mar 2011
- Location
- Winchester, UK
- Posts
- 1,680
- Thanks
- 1,307
- Thanked 951 Times in 523 Posts
Of course the battery drain will be higher than if you didn't have it all, but I don't think it will be that high. It would take like a second for it to find your location. Then that's it. Maybe do that once an hour/30 min. That's not a whole deal. If some HighTechCrap can do it I'm pretty sure the iPhone can with little issue.

-
01-30-2012, 03:28 PM #14
I'm so glad we have gotten interest in this project, unfortunately the computer I was using to SSH into my phone and work on code the power supply died last week, so I am using an old Mac-Mini but its slow and a pain to use, so I am thinking I am out of commission to work on anything with this for a while. But if anyone can figure this out that would be awesome.
If it ain't broke, you haven't tried hard enough
-
02-02-2012, 12:21 PM #15
So, i too am interested in this and have been pursuing it for the last couple of days. What I have come up with so far is that I cannot get the geolocation to run when its called...
When I do tests on my pc, I'm able to get my geolocation (of the pc, based on IP i assume) and then have it do a lookup at weather.com. When it does the lookup using my lat/long, i can return my weather code. Finally I can input that into the yahoo xml call for the weather, and it looks all good.
But again, this is on my PC.
When it comes to my iPhone, I can't get the geolocation to run from the main theme. It completely skips the function call. Without going into too much detail, here's what i have. Maybe someone can spot what i might have wrong:
in the widget.html:
<body onLoad="onLoad();">
<div id="TextContainer"><a id="lat"></a><a id="lng"></a></div>
</body>
then in the javascript:
function onLoad(){
fetchLocation();
...
}
The only piece of importance is the fetchLocation function:
function fetchLocation() {
document.getElementById("lat").innerText = 1
navigator.geolocation.getCurrentPosition(getLocati on,null);
document.getElementById("lng").innerText = 2
}
function getLocation(position) {
lat = position.coords.latitude;
lng = position.coords.longitude;
getLocId(lat,lng);
}
function getLocId (lat, lng){
... <secret sauce of the program> ...
}
so you can see that when the fetchLocation is first called, i'd be inputting 1 and 2 into lat and lng on the widget.html, but those aren't even being populated cause the function isn't running.
So does the springboard html not allow location service calls?
-
02-02-2012, 02:29 PM #16
Does not seem to work on Lockscreen or wallpaper.html.
-
02-02-2012, 02:35 PM #17
I was thinking about this more, and whenever the geolocation is used, there is always a popup window (javascript alert) that says would you like to use location services.
Obviously that is not happening, and i think the code is just quitting right then and there.
-
02-02-2012, 02:42 PM #18Livin the iPhone Life
- Join Date
- Mar 2011
- Location
- Winchester, UK
- Posts
- 1,680
- Thanks
- 1,307
- Thanked 951 Times in 523 Posts
Have you tried using it in perpagehtml app? It may work slightly different than winterboard.

-
02-02-2012, 03:17 PM #19
I have, and didn't have any luck there either.
-
02-02-2012, 10:31 PM #20
I was thinking about what you want to do and it would be very nice.
The question is how does the stock weather app generate the weather code for Yahoo LOCAL weather? Perhaps that is the path to follow.
I am a coding NOOB but I found these which may or may not be helpful.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>OverrideLocation</key>
<false/>
<key>Location</key>
<string>20852</string>
...
OverrideLocation - Boolean setting for whether to use the Apple weather application settings or the settings in this file. Defaults to false, meaning use the Apple weather application. The first location from the Apple weather application will be used.
Also please see the Yahoo Developer info.
See:
Yahoo! PlaceFinder Guide - YDN
Yahoo PlaceFinder
See: Yahoo! PlaceFinder - YDNPlaceFinder recognizes a large number of place formats and returns rich geographic data about each result, including geographic coordinates, address components, and WOEID.
See: Requests - YDNYahoo! PlaceFinder is a REST Web service, accessible at the following URI:
http://where.yahooapis.com/geocode?[parameters]
The PlaceFinder Web service supports only the HTTP GET method. Other HTTP methods are not supported.
The appid parameter and at least one location parameter are required for all requests. Reserved characters in the parameters must be URL-encoded. All text in the request must be UTF-8 encoded.
Latitude and Longitude
Latitude and longitude can be specified for the location parameter. Latitude and longitude may be expressed as decimal degrees or degrees-minutes-seconds, with either leading or trailing directionals or leading signs. If directionals are provided, longitude may appear before latitude. If directionals are not provided, longitude may appear before latitude if it is outside the range -90 to 90. Otherwise, the latitude must appear first. Punctuation marks (commas, degrees, minutes, seconds) are ignored.
Examples:
50.3 -120.5
50.3, -120.5
-120.5 50.3
50.3 N 120.5 W
120.5 W 50.3 N
50 18 0 -120 30 0
50 18 0 N 120 30 0 W
50° 18' 0" N 120° 30' 0" WSee: Responses - YDNResponses
...
ELEMENTS
The following tables describe the data elements in a response.
...
woeid Integer Where On Earth ID for area. Returned if C flag is not set.
Good Luck, we are all counting on you.Request URI:
*ttp://where.yahooapis.com/geocode?location=37.787082+-122.400929&gflags=R&appid=yourappid
Response Data:
<?xml version="1.0" encoding="UTF-8"?>
<ResultSet version="1.0">
<Error>0</Error>
<ErrorMessage>No error</ErrorMessage>
<Locale>us_US</Locale>
<Quality>99</Quality>
<Found>1</Found>
<Result>
<quality>99</quality>
<latitude>37.787082</latitude>
<longitude>-122.400929</longitude>
<offsetlat>37.787082</offsetlat>
<offsetlon>-122.400929</offsetlon>
<radius>500</radius>
<name>37.787082 -122.400929</name>
<line1>655 Mission St</line1>
<line2>San Francisco, CA 94105-4126</line2>
<line3/>
<line4>United States</line4>
<house>655</house>
<street>Mission St</street>
<xstreet/>
<unittype/>
<unit/>
<postal>94105-4126</postal>
<neighborhood/>
<city>San Francisco</city>
<county>San Francisco County</county>
<state>California</state>
<country>United States</country>
<countrycode>US</countrycode>
<statecode>CA</statecode>
<countycode/>
<hash/>
<woeid>12797156</woeid>
<woetype>11</woetype>
<uzip>94105</uzip>
</Result>
</ResultSet>
Last edited by squawpeakguy; 02-02-2012 at 11:18 PM.



LinkBack URL
About LinkBacks
Reply With Quote
