├── .meteor ├── .gitignore ├── release ├── platforms ├── cordova-plugins ├── .finished-upgraders ├── .id ├── packages └── versions ├── server ├── index.js └── publications.js ├── client ├── views │ ├── home.html │ ├── header.html │ ├── app_layout.html │ └── home.js └── cordova.js ├── lib └── router.js └── collections └── places.js /.meteor/.gitignore: -------------------------------------------------------------------------------- 1 | local 2 | -------------------------------------------------------------------------------- /.meteor/release: -------------------------------------------------------------------------------- 1 | METEOR@1.0.2.1 2 | -------------------------------------------------------------------------------- /.meteor/platforms: -------------------------------------------------------------------------------- 1 | server 2 | browser 3 | -------------------------------------------------------------------------------- /.meteor/cordova-plugins: -------------------------------------------------------------------------------- 1 | org.apache.cordova.geolocation@0.3.10 2 | -------------------------------------------------------------------------------- /server/index.js: -------------------------------------------------------------------------------- 1 | Places._ensureIndex({'loc.coordinates':'2dsphere'}); 2 | -------------------------------------------------------------------------------- /client/views/home.html: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /client/views/header.html: -------------------------------------------------------------------------------- 1 | 8 | -------------------------------------------------------------------------------- /server/publications.js: -------------------------------------------------------------------------------- 1 | Meteor.publish('nearbyPlaces', function(bottomLeft, topRight) { 2 | if (!bottomLeft && !topRight) { 3 | return []; 4 | } 5 | return Places.find( { loc : { $geoWithin :{ $box : [bottomLeft, topRight]} }}) 6 | }); 7 | -------------------------------------------------------------------------------- /client/cordova.js: -------------------------------------------------------------------------------- 1 | Meteor.startup(function() { 2 | navigator.geolocation.getCurrentPosition(success); 3 | }); 4 | 5 | success = function(position) { 6 | Session.set('location', position); 7 | Meteor.call('fetchNearbyLocations', position.coords) 8 | } 9 | -------------------------------------------------------------------------------- /.meteor/.finished-upgraders: -------------------------------------------------------------------------------- 1 | # This file contains information which helps Meteor properly upgrade your 2 | # app when you run 'meteor update'. You should check it into version control 3 | # with your project. 4 | 5 | notices-for-0.9.0 6 | notices-for-0.9.1 7 | 0.9.4-platform-file 8 | -------------------------------------------------------------------------------- /lib/router.js: -------------------------------------------------------------------------------- 1 | Router.configure({ 2 | layoutTemplate: 'appLayout' 3 | }) 4 | 5 | Router.route('/', { 6 | template: 'Home', 7 | waitOn: function() { 8 | return Meteor.subscribe('nearbyPlaces', Session.get('bottomLeft'), Session.get('topRight')) 9 | }, 10 | data: function () { return Places.find() } 11 | }) 12 | -------------------------------------------------------------------------------- /.meteor/.id: -------------------------------------------------------------------------------- 1 | # This file contains a token that is unique to your project. 2 | # Check it into your repository along with the rest of this directory. 3 | # It can be used for purposes such as: 4 | # - ensuring you don't accidentally deploy one app on top of another 5 | # - providing package authors with aggregated statistics 6 | 7 | 1fatqjl1xfmzfwu08hd 8 | -------------------------------------------------------------------------------- /.meteor/packages: -------------------------------------------------------------------------------- 1 | # Meteor packages used by this project, one per line. 2 | # Check this file (and the other files in this directory) into your repository. 3 | # 4 | # 'meteor add' and 'meteor remove' will edit this file for you, 5 | # but you can also edit it by hand. 6 | 7 | meteor-platform 8 | insecure 9 | iron:router 10 | pcjpcj2:ratchet 11 | http 12 | -------------------------------------------------------------------------------- /client/views/app_layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 15 | -------------------------------------------------------------------------------- /collections/places.js: -------------------------------------------------------------------------------- 1 | Places = new Mongo.Collection('places'); 2 | 3 | Meteor.methods({ 4 | 'fetchNearbyLocations': function(coords) { 5 | if (Meteor.isServer) { 6 | results = HTTP.get("https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=" + coords.latitude + "," + coords.longitude + "&radius=500&types=food&key=AIzaSyCtfoCAldCEf8hXUlkVUd4UljqKR6W_aF4") 7 | console.log(results) 8 | _(results.data.results).each(function(loc) { 9 | _.extend(loc, {loc: {type: "Point", coordinates: [loc.geometry.location.lng, loc.geometry.location.lat]}}) 10 | Places.upsert({id: loc.id}, {$set: loc}) 11 | }); 12 | } 13 | } 14 | }); 15 | -------------------------------------------------------------------------------- /.meteor/versions: -------------------------------------------------------------------------------- 1 | application-configuration@1.0.4 2 | autoupdate@1.1.4 3 | base64@1.0.2 4 | binary-heap@1.0.2 5 | blaze@2.0.4 6 | blaze-tools@1.0.2 7 | boilerplate-generator@1.0.2 8 | callback-hook@1.0.2 9 | check@1.0.3 10 | ddp@1.0.13 11 | deps@1.0.6 12 | ejson@1.0.5 13 | fastclick@1.0.2 14 | follower-livedata@1.0.3 15 | geojson-utils@1.0.2 16 | html-tools@1.0.3 17 | htmljs@1.0.3 18 | http@1.0.9 19 | id-map@1.0.2 20 | insecure@1.0.2 21 | iron:controller@1.0.6 22 | iron:core@1.0.6 23 | iron:dynamic-template@1.0.6 24 | iron:layout@1.0.6 25 | iron:location@1.0.6 26 | iron:middleware-stack@1.0.6 27 | iron:router@1.0.6 28 | iron:url@1.0.6 29 | jquery@1.0.2 30 | json@1.0.2 31 | launch-screen@1.0.1 32 | livedata@1.0.12 33 | logging@1.0.6 34 | meteor@1.1.4 35 | meteor-platform@1.2.1 36 | minifiers@1.1.3 37 | minimongo@1.0.6 38 | mobile-status-bar@1.0.2 39 | mongo@1.0.11 40 | observe-sequence@1.0.4 41 | ordered-dict@1.0.2 42 | pcjpcj2:ratchet@2.0.2 43 | random@1.0.2 44 | reactive-dict@1.0.5 45 | reactive-var@1.0.4 46 | reload@1.1.2 47 | retry@1.0.2 48 | routepolicy@1.0.3 49 | session@1.0.5 50 | spacebars@1.0.4 51 | spacebars-compiler@1.0.4 52 | templating@1.0.10 53 | tracker@1.0.4 54 | ui@1.0.5 55 | underscore@1.0.2 56 | url@1.0.3 57 | webapp@1.1.5 58 | webapp-hashing@1.0.2 59 | -------------------------------------------------------------------------------- /client/views/home.js: -------------------------------------------------------------------------------- 1 | Template.home.rendered = function() { 2 | Tracker.autorun(function() { 3 | if (Session.get('location')) { 4 | latitude = Session.get('location').coords.latitude; 5 | longitude = Session.get('location').coords.longitude; 6 | var map = L.map('map').setView([latitude, longitude], 15); 7 | L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { 8 | attribution: '© OpenStreetMap contributors' 9 | }).addTo(map); 10 | bounds = map.getBounds(); 11 | if (bounds) { 12 | Session.set('bottomLeft', [bounds._southWest.lng, bounds._southWest.lat]); 13 | Session.set('topRight', [bounds._northEast.lng, bounds._northEast.lat]); 14 | } 15 | if (Template.instance().data) { 16 | Template.instance().data.forEach(function(place) { 17 | L.marker([place.geometry.location.lat, place.geometry.location.lng]).addTo(map) 18 | .bindPopup("" + place.name + "
" + place.vicinity); 19 | }); 20 | } 21 | map.on('moveend', function(event) { 22 | bounds = event.target.getBounds() 23 | Session.set('bottomLeft', [bounds._southWest.lng, bounds._southWest.lat]); 24 | Session.set('topRight', [bounds._northEast.lng, bounds._northEast.lat]); 25 | coords = {latitude: event.target.getCenter().lat, longitude: event.target.getCenter().lng} 26 | Session.set('location', {coords: coords}) 27 | Meteor.call('fetchNearbyLocations', coords) 28 | }); 29 | } 30 | }); 31 | } 32 | --------------------------------------------------------------------------------