diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2020-04-19 12:15:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-19 12:15:53 -0700 |
commit | 665daf83ceade22def940066905e366d9529b60b (patch) | |
tree | c45b17b0af9a55ec65ec29d4e1b13bf65aff1f9b /web | |
parent | 3973030c9d7795779e6b3d309e6788f5b7077ecb (diff) | |
parent | 1b38178d0fb79ae82a51f5754ddf51f3c1c09a5c (diff) | |
download | trackermap-web-665daf83ceade22def940066905e366d9529b60b.tar.gz trackermap-web-665daf83ceade22def940066905e366d9529b60b.tar.bz2 trackermap-web-665daf83ceade22def940066905e366d9529b60b.zip |
Merge pull request #775 from kristian/master
Add long/lat/zoom URI parameters to simple UI
Diffstat (limited to 'web')
-rw-r--r-- | web/simple/app.js | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/web/simple/app.js b/web/simple/app.js index ed889f19..0c44bae5 100644 --- a/web/simple/app.js +++ b/web/simple/app.js @@ -29,8 +29,12 @@ if (!Array.prototype.find) { }); } +var getQueryParameter = function(name) { + return (window.location.search.match('[?&]' + name + '=([^&]*)') || [])[1]; +}; + var url = window.location.protocol + '//' + window.location.host; -var token = (window.location.search.match(/token=([^&#]+)/) || [])[1]; +var token = getQueryParameter('token'); var style = function (label) { return new ol.style.Style({ @@ -98,10 +102,10 @@ ajax('GET', url + '/api/server', function(server) { ajax('GET', url + '/api/session?token=' + token, function(user) { map.getView().setCenter(ol.proj.fromLonLat([ - user.longitude || server.longitude || 0.0, - user.latitude || server.latitude || 0.0 + parseFloat(getQueryParameter('longitude')) || user.longitude || server.longitude || 0.0, + parseFloat(getQueryParameter('latitude')) || user.latitude || server.latitude || 0.0 ])); - map.getView().setZoom(user.zoom || server.zoom || 2); + map.getView().setZoom(parseFloat(getQueryParameter('zoom')) || user.zoom || server.zoom || 2); ajax('GET', url + '/api/devices', function(devices) { |