Skip to content
Browse files

Merge branch 'master' of github.com:paulcuth/apidevday

Conflicts:
	index.html
	js/site.js
  • Loading branch information...
2 parents e038549 + 34fed66 commit a7f2a104ecc8778b82f06ccb56ca1dc3716f881a @paulcuth committed
Showing with 26 additions and 14 deletions.
  1. +2 −0 js/nestoria.js
  2. +24 −14 js/site.js
View
2 js/nestoria.js
@@ -18,6 +18,8 @@ window.NESTORIA = (function($){
nester.request_avg = function(coords, radius, callback) {
var coords_param = coords[0] + ',' + coords[1],
new_url = coords_url.replace('%coords', coords_param).replace('%radius', radius),
+ data;
+ console.log(new_url);
data = get_nest_data(new_url, function(nest_data, textStatus) {
// Process nest_data
latest_data = nest_data;
View
38 js/site.js
@@ -1,7 +1,8 @@
(function () {
- var last_lat, last_lng,
- map;
+ var last_lat = 51.497,
+ last_lng = -0.122,
+ map;
function init () {
var lat = sessionStorage? sessionStorage['lat'] || 51.497977 : 51.497977,
@@ -28,6 +29,11 @@
var c = map.getCenter ();
getData (c.lat (), c.lng (), getRadius ());
+
+ google.maps.event.addListener(map, 'zoom_changed', function(){
+ console.log('zoom changed');
+ getData();
+ })
}
@@ -49,32 +55,36 @@
return Math.round(coord * 1000) / 1000;
}
+
function getData (lat, lng, radius) {
var changed = false;
lat = narrowCoord(lat);
lng = narrowCoord(lng);
- if(last_lat !== lat){
- last_lat = lat;
- changed = true;
- }
- if(last_lng !== lng){
- last_lng = lng;
- changed = true;
+ if(!lat){
+ last_lat = 51.497;
+ last_lng = -0.122;
+ changed = true;
+ } else {
+ if(last_lat !== lat){
+ last_lat = lat;
+ changed = true;
+ }
+ if(last_lng !== lng){
+ last_lng = lng;
+ changed = true;
+ }
}
if(changed){
- NESTORIA.request_avg([last_lat, last_lng], '10km', function(data){
+ NESTORIA.request_avg([last_lat, last_lng], getRadius() + 'km', function(data){
// Get average
+
console.log(NESTORIA.get_avgs(false));
})
}
-
- //$('#data').text (last_lat + ', ' + last_lng);
}
-
init ();
-
})();

0 comments on commit a7f2a10

Please sign in to comment.
Something went wrong with that request. Please try again.