felixhageloh / weather-widget

A weather widget for Übersicht
64 stars 32 forks source link

Found a solution to auto location not working #31

Closed aaronvb closed 8 years ago

aaronvb commented 8 years ago

For those that are having problems with the auto location, it's due to freegeoip.net being down. As far as I can tell it's been down for a while.

I've found an alternative free IP geolocation service(http://ip-api.com) and it's very easy to modify the current get-weather code to use it.

At https://github.com/felixhageloh/weather-widget/blob/master/weather.widget/get-weather#L31, change:

var request = getJSON("http://freegeoip.net/json/", callback);

to

var request = getJSON("http://ip-api.com/json", callback);

The API returns a region attribute instead of region_name, so change https://github.com/felixhageloh/weather-widget/blob/master/weather.widget/get-weather#L20

options.region = location.region_name;

to

options.region = location.region;

If this is something you want in this repo I can make a PR.

felixhageloh commented 8 years ago

great! PR is welcome - have little time to work on this widget right now!

TakingBackTj commented 8 years ago

Aaron - I have tried your fix, and it doesnt seem to have worked for me... I have edited the get-weather document as stated, yet I get this error message where the widget should be on my desktop http://imgur.com/uvtKw3S any ideas?

aaronvb commented 8 years ago

@TakingBackTj Not sure why there's a syntax error. Can you confirm that going to http://ip-api.com/json in your browser outputs valid data(ie: city, region, etc)?

felixhageloh commented 8 years ago

I just merged @aaronvb pull request which hopefully fixes this