From 21c86c6d6dbb9507c1f17a2d6afd4dc6650adc08 Mon Sep 17 00:00:00 2001 From: Quincy Morgan <2046746+quincylvania@users.noreply.github.com> Date: Sun, 13 Sep 2020 17:09:35 -0400 Subject: [PATCH] Re-add reading of mapillary image from URL (re: #7885, #6398) --- modules/renderer/photos.js | 18 ++++++++++++++++++ modules/services/mapillary.js | 8 +------- 2 files changed, 19 insertions(+), 7 deletions(-) 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; }