Created
September 14, 2012 12:36
-
-
Save rbrancher/3721673 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SERVER | |
Meteor.startup(function () { | |
// code to run on server at startup | |
Coords = new Meteor.Collection("coords"); | |
Meteor.publish('coords', function () { | |
return Coords.find(); | |
}); | |
}); | |
// CLIENT | |
Coords = new Meteor.Collection("coords"); | |
Meteor.subscribe('coords'); | |
Template.coordsList.coords = function () { | |
return Coords.find(); | |
} | |
if ("geolocation" in navigator) { | |
var registerCoords = function (latitude, longitude) { | |
Coords.insert({latitude: latitude, longitude: longitude}); | |
} | |
navigator.geolocation.getCurrentPosition(function (position) { | |
registerCoords(position.coords.latitude, position.coords.longitude); | |
}); | |
} else { | |
alert("I'm sorry, but geolocation services are not supported by your browser."); | |
} | |
// TEMPLATES | |
<head> | |
<title>vá de moto!</title> | |
</head> | |
<body> | |
<h1>vá de moto!</h1> | |
{{> coordsList}} | |
</body> | |
<template name="coordsList"> | |
<h2>waypoints</h2> | |
<ul id="coordsList"> | |
{{#each coords}} | |
<li class="coord"><a href="https://maps.google.com/maps?q={{latitude}},+{{longitude}}&z=16" target="_new">{{latitude}}, {{longitude}}</a></li> | |
{{/each}} | |
</ul> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment