diff --git a/client/scripts/application.js b/client/scripts/application.js index adfd7f8..3db6bcb 100644 --- a/client/scripts/application.js +++ b/client/scripts/application.js @@ -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 || {}));