Pass geolocation data to server
This commit is contained in:
parent
10599e9c66
commit
c7de890a8f
@ -27,7 +27,7 @@
|
||||
(function(hscd) {
|
||||
'use strict';
|
||||
|
||||
var _ctx = { log: [] };
|
||||
var _ctx = { };
|
||||
|
||||
function onAdjust(name, value) {
|
||||
_ctx.query.features[name] = value;
|
||||
@ -38,7 +38,12 @@
|
||||
});
|
||||
}
|
||||
|
||||
function onReady() {
|
||||
function onReady(geo) {
|
||||
_ctx = {
|
||||
log: [],
|
||||
geo: geo
|
||||
};
|
||||
|
||||
$('#historyIndex').slider({
|
||||
formatter: function(value) {
|
||||
var delta = _ctx.log.length - (value + 1);
|
||||
@ -131,6 +136,11 @@
|
||||
maxResults: parseInt($('#maxResults').val())
|
||||
};
|
||||
|
||||
if (_ctx.geo) {
|
||||
_ctx.query.latitude = _ctx.geo.coords.latitude;
|
||||
_ctx.query.longitude = _ctx.geo.coords.longitude;
|
||||
}
|
||||
|
||||
if (!_.has(_ctx, 'grapher')) {
|
||||
_ctx.grapher = new grapher.Grapher({
|
||||
canvas: new Snap('#svg'),
|
||||
@ -233,6 +243,11 @@
|
||||
$('#spinner').hide();
|
||||
},
|
||||
|
||||
ready: onReady()
|
||||
ready: function() {
|
||||
navigator.geolocation.getCurrentPosition(
|
||||
function(geo) { onReady(geo); },
|
||||
function(err) { onReady(null); }
|
||||
);
|
||||
}
|
||||
});
|
||||
}(window.hscd = window.hscd || {}));
|
||||
|
Loading…
Reference in New Issue
Block a user