From 9ebf3b11a4f10ad3dae08efd1e254afbfdac4a72 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Fri, 26 Jan 2018 15:45:53 -0500 Subject: [PATCH] Don't initialize Mapillary viewer with a key (closes #4536) This avoids binding the viewer to an image key that might not be fully processed, which gets the viewer into a bad state. Instead, we initialize the viewer with a `null` image key and issue `moveToKey` immediately. This commit also adds exception handling for moveToKey. --- modules/services/mapillary.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/services/mapillary.js b/modules/services/mapillary.js index 23efc1573..b37f9641f 100644 --- a/modules/services/mapillary.js +++ b/modules/services/mapillary.js @@ -514,7 +514,8 @@ export default { if (!_mlyViewer) { this.initViewer(imageKey, context); } else { - _mlyViewer.moveToKey(imageKey); + _mlyViewer.moveToKey(imageKey) + .catch(function(e) { console.error('mly3', e); }); // eslint-disable-line no-console } return this; @@ -533,8 +534,10 @@ export default { } }; - _mlyViewer = new Mapillary.Viewer('mly', clientId, imageKey, opts); + _mlyViewer = new Mapillary.Viewer('mly', clientId, null, opts); _mlyViewer.on('nodechanged', nodeChanged); + _mlyViewer.moveToKey(imageKey) + .catch(function(e) { console.error('mly3', e); }); // eslint-disable-line no-console } // nodeChanged: called after the viewer has changed images and is ready.