fix api error with undefined cities (somehow)
This commit is contained in:
parent
0a16ba3d9d
commit
17f77c99bd
|
@ -54,7 +54,6 @@ function DataManager(pointSearch){
|
|||
locList.push({lat: latgeo, long:longeo, distance:dist, stationUrl:feature.stationId[i]});
|
||||
}
|
||||
}
|
||||
|
||||
if (locList.length===0) {
|
||||
$this.trigger('allinit');
|
||||
return
|
||||
|
|
|
@ -55,10 +55,11 @@ function Location() { // onReady, onRefresh, onAllComplete
|
|||
|
||||
// ajax the latest observation
|
||||
$.getJSON(url, function(data) {
|
||||
if (data['v3-location-point'] != null) {
|
||||
_observations[0] = json = data['v3-wx-observations-current'];
|
||||
_observations[0].latitude = loclat;
|
||||
_observations[0].longitude = loclong;
|
||||
_observations[0].cityname = data['v3-location-point'].location.city;
|
||||
_observations[0].cityname = data['v3-location-point'].location.displayName;
|
||||
$this.trigger('refresh');
|
||||
|
||||
// the following block only runs on init
|
||||
|
@ -71,14 +72,16 @@ function Location() { // onReady, onRefresh, onAllComplete
|
|||
|
||||
that.city = data['v3-location-point'].location.city;
|
||||
|
||||
$this.trigger('init');
|
||||
|
||||
$this.trigger('init');
|
||||
}
|
||||
// set the expiration date/time
|
||||
_observations[0].xdate = dateFns.addMinutes(json.lastBuildDate, json.ttl);
|
||||
|
||||
setTimeout(checkRefresh, getRandom(5000, 10000));
|
||||
|
||||
} else {
|
||||
$this.trigger('init');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -1211,9 +1211,11 @@ RADAR < MAIN CITY < CITY 1 < CITY 2
|
|||
airport='<span class="city airport">AIRPORTS</span>';
|
||||
|
||||
for (var location of dataMan.locations) {
|
||||
if (location.city !== undefined) {
|
||||
city = location.city;
|
||||
cities += arrow+'<span class="city" data-woeid="' + location.woeid + '">' + city + '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
$('#info-slides-header .hscroller').append(cities + arrow + (radar + arrow + airport + arrow + health + cities + arrow).repeat(4));
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ function WeatherManager() {
|
|||
var queryString = window.location.search;
|
||||
|
||||
if (queryString) {
|
||||
$.getJSON("https://api.weather.com/v3/location/search?query="+queryString.split("?")[1]+"&language=en-US&format=json&apiKey=" + process.env.API_KEY, function(data) {
|
||||
$.getJSON("https://api.weather.com/v3/location/search?query="+queryString.split("?")[1]+"&language=en-US&format=json&apiKey=" + api_key, function(data) {
|
||||
dataMan = createDataManager( data.location.latitude[0]+','+data.location.longitude[0] );
|
||||
mainloc = data.location.city[0]
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue