diff --git a/modules/renderer/photos.js b/modules/renderer/photos.js index 62eb89ce9..2a406247e 100644 --- a/modules/renderer/photos.js +++ b/modules/renderer/photos.js @@ -1,5 +1,6 @@ import { dispatch as d3_dispatch } from 'd3-dispatch'; +import { services } from '../services'; import { utilRebind } from '../util/rebind'; import { utilQsString, utilStringQs } from '../util'; @@ -81,6 +82,23 @@ export function rendererPhotos(context) { if (layer) layer.enabled(true); }); } + if (hash.photo) { + var photoIds = hash.photo.replace(/;/g, ',').split(','); + var photoId = photoIds.length && photoIds[0].trim(); + var results = /(.*)-(.*)/g.exec(photoId); + if (results && results.length >= 3) { + var serviceId = results[1]; + var photoKey = results[2]; + var service = services[serviceId]; + if (service.ensureViewerLoaded) { + service.ensureViewerLoaded(context) + .then(function() { + service.updateViewer(context, photoKey); + service.showViewer(context); + }); + } + } + } context.layers().on('change.rendererPhotos', updateStorage); }; diff --git a/modules/services/mapillary.js b/modules/services/mapillary.js index 01d0ff06c..daddd68d8 100644 --- a/modules/services/mapillary.js +++ b/modules/services/mapillary.js @@ -448,12 +448,6 @@ export default { }) .then(function() { that.initViewer(context); - - var hash = utilStringQs(window.location.hash); - if (hash.photo) { - that.updateViewer(context, hash.photo); - that.showViewer(context); - } }); return _loadViewerPromise; @@ -546,7 +540,7 @@ export default { if (!window.mocha) { var hash = utilStringQs(window.location.hash); if (imageKey) { - hash.photo = imageKey; + hash.photo = 'mapillary-' + imageKey; } else { delete hash.photo; }