From cd30ab5d3c482e4ebc957721362e5f5d9efcd419 Mon Sep 17 00:00:00 2001 From: Sean Legg Date: Tue, 21 Feb 2012 11:12:18 +0000 Subject: [PATCH] Work on mash/hash/cache section.! --- client/default/app/controllers/Map.js | 41 ++++++++++++++++++++++----- cloud/main.js | 18 ++++++++++-- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/client/default/app/controllers/Map.js b/client/default/app/controllers/Map.js index e939405..d44a97c 100755 --- a/client/default/app/controllers/Map.js +++ b/client/default/app/controllers/Map.js @@ -10,11 +10,39 @@ app.controllers.map = new Ext.Controller({ } }, + getPoints: function(map, callback) { + $fh.act({ + act: 'getPoints', + req: {} + }, function(res) { + var mapMarkets = JSON.parse(res); + if (mapMarkets) { + for (var i = 0; i < mapMarkets.points.length; i++) { + var point = mapMarkets.points[i]; + var pos = new google.maps.LatLng(point.lat, point.lon); + + app.controllers.map.markers.push(new google.maps.Marker({ + position: pos, + map: map, + icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|FF0000|000000' + })); + } + } + + if (typeof callback !== "undefined") { + callback(); + } + }); + }, + getLocation: function(options){ // Instance of the google map var map = Ext.getCmp("map").map; var pos = {}; + // Show loading spinner + mark.show(); + $fh.geo({ interval: 0 }, function(res){ @@ -24,22 +52,21 @@ app.controllers.map = new Ext.Controller({ // Remove any previously created markers app.controllers.map.clearMarkers(); - // Create a marker + // Create a marker at the current location app.controllers.map.markers.push(new google.maps.Marker({ position: pos, map: map, icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=A|FF0000|000000' })); + + // Get markers from the cloud + app.controllers.map.getPoints(map, function() { + mask.hide() + }); }, function() { // We failed to get the users geolocation, fallback to geo ip alert("$fh.geo failed"); alert(JSON.stringify(res.geoip)); - - /* - $fh.geoip(function(res) { - console.log(JSON.stringify(res.geoip)); - }); - */ }); } diff --git a/cloud/main.js b/cloud/main.js index 6a73284..f0b8508 100755 --- a/cloud/main.js +++ b/cloud/main.js @@ -1,7 +1,4 @@ function getTweets() { - //var url = 'http://api.twitter.com/1/statuses/user_timeline/' + username + '.json?callback=?'; - //var url = 'https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=' + username + '&count=' + num_tweets; - var username = 'feedhenry'; var num_tweets = 10; var url = 'http://search.twitter.com/search.json?q=' + username; @@ -11,4 +8,19 @@ function getTweets() { method: 'GET', allowSelfSignedCert: true }); +} + +function getPoints() { + return { + locations: [ + { + lat: '52.245671', + lon: '-7.080002' + }, + { + lat: '52.257861', + lon: '-7.136993' + } + ] + } } \ No newline at end of file