diff --git a/modules/renderer/photos.js b/modules/renderer/photos.js index d71d64e96..daefdf2e3 100644 --- a/modules/renderer/photos.js +++ b/modules/renderer/photos.js @@ -50,17 +50,35 @@ export function rendererPhotos(context) { return val === _dateFilters[0] ? _fromDate : _toDate; }; - photos.setDateFilter = function(type, val) { + photos.setDateFilter = function(type, val, updateUrl) { if (type === _dateFilters[0]) _fromDate = val; if (type === _dateFilters[1]) _toDate = val; dispatch.call('change', this); + if (updateUrl) { + setUrlFilterValue(type, val); + } }; - photos.setUsernameFilter = function(val) { + photos.setUsernameFilter = function(val, updateUrl) { _username = val; dispatch.call('change', this); + if (updateUrl) { + setUrlFilterValue('username', val); + } }; + function setUrlFilterValue(type, val) { + if (!window.mocha) { + var hash = utilStringQs(window.location.hash); + if (val) { + hash[type] = val; + } else { + delete hash[type]; + } + window.location.replace('#' + utilQsString(hash, true)); + } + } + function showsLayer(id) { var layer = context.layers().layer(id); return layer && layer.supported() && layer.enabled(); @@ -127,6 +145,15 @@ export function rendererPhotos(context) { if (layer && !layer.enabled()) layer.enabled(true); }); } + if (hash.fromDate) { + this.setDateFilter('fromDate', hash.fromDate, false); + } + if (hash.toDate) { + this.setDateFilter('toDate', hash.toDate, false); + } + if (hash.username) { + this.setUsernameFilter(hash.username, false); + } if (hash.photo) { // support opening a photo via a URL parameter, e.g. `photo=mapillary-fztgSDtLpa08ohPZFZjeRQ` diff --git a/modules/ui/sections/photo_overlays.js b/modules/ui/sections/photo_overlays.js index 58087be84..2986d6083 100644 --- a/modules/ui/sections/photo_overlays.js +++ b/modules/ui/sections/photo_overlays.js @@ -220,7 +220,7 @@ export function uiSectionPhotoOverlays(context) { }) .on('change', function(d) { var value = d3_select(this).property('value'); - context.photos().setDateFilter(d, value); + context.photos().setDateFilter(d, value, true); }); li @@ -275,7 +275,7 @@ export function uiSectionPhotoOverlays(context) { .property('value', context.photos().username()) .on('change', function() { var value = d3_select(this).property('value'); - context.photos().setUsernameFilter(value); + context.photos().setUsernameFilter(value, true); }); li