Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
71 lines (58 sloc) 1.85 KB
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
</script>
{% for row in rows %}
<div>
{% for col in row %}
<span style="border:1px black solid;margin:3px;">{{col}}</span>
{% end %}
</div>
{% end %}
<div id="status"></div>
<article></article>
<script>
function success(position) {
var s = document.querySelector('#status');
s.innerHTML = "found you at " +
position.coords.latitude + ", " +
position.coords.longitude;
s.className = 'success';
var client = new XMLHttpRequest();
client.open("POST", "/waypoint");
client.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
client.send(JSON.stringify({
'position':position,
'trip_id':{{ trip_id }},
}));
var mapcanvas = document.createElement('div');
mapcanvas.id = 'mapcanvas';
mapcanvas.style.height = '400px';
mapcanvas.style.width = '560px';
document.querySelector('article').appendChild(mapcanvas);
var latlng = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
var myOptions = {
zoom: 15,
center: latlng,
mapTypeControl: false,
navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("mapcanvas"), myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map,
title:"You are here!"
});
setTimeout(function() { navigator.geolocation.getCurrentPosition(success, error); },
1000);
}
function error(msg) {
var s = document.querySelector('#status');
s.innerHTML = typeof msg == 'string' ? msg : "failed";
s.className = 'fail';
// console.log(arguments);
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
}
</script>
Something went wrong with that request. Please try again.