Commits

Rufus Pollock committed 481457a

[lib][s]: set proper username for geonames and handle errors from geonames more gracefully.

Comments (0)

Files changed (2)

     }
     if (parsed.location && parsed.location.unparsed != '') {
       HyperNotes.Util.lookupLocation(parsed.location.unparsed, function(data) {
-        parsed.location.geonames = data;
-        parsed.location.centroid = [
-          data.lng,
-          data.lat
-        ];
+        if (!data) {
+          alert('Failed to geolocate location: ' + parsed.location.unparsed);
+        } else {
+          parsed.location.geonames = data;
+          parsed.location.centroid = [
+            data.lng,
+            data.lat
+          ];
+        }
         callback(new my.Note(parsed));
       });
     } else {
   };
 
   my.lookupLocation = function(name, callback) {
-    var geonamesApi = 'http://api.geonames.org/searchJSON?maxRows=1&username=demo&q=';
+    var geonamesApi = 'http://api.geonames.org/searchJSON?maxRows=1&username=okfn&q=';
     var queryUrl = geonamesApi + name;
     $.getJSON(queryUrl, function(data) {
       // strip off stuff