From ec4b00b7e1a88479c8ee008c3ecde35dc0acb2b1 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sun, 16 Jul 2017 11:15:43 -0400 Subject: [PATCH] Call selectedImage again from nodeChanged to update detections, capturedAt --- modules/services/mapillary.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/services/mapillary.js b/modules/services/mapillary.js index 64f98faa3..a21a5110f 100644 --- a/modules/services/mapillary.js +++ b/modules/services/mapillary.js @@ -438,14 +438,27 @@ export default { mapillaryViewer.on('nodechanged', nodeChanged); } + // nodeChanged: called after the viewer has changed images and is ready. + // + // There is some logic here to batch up clicks into a mapillaryClicks array + // because the user might click on a lot of markers quickly and nodechanged + // may be called out of order asychronously. + // + // Clicks are added to the array in `selectedImage` and removed here. + // function nodeChanged(node) { mapillaryViewer.getComponent('tag').removeAll(); // remove previous detections var clicks = mapillaryClicks; var index = clicks.indexOf(node.key); - if (index > -1) { // nodechange initiated from clicking on a marker.. + if (index > -1) { // `nodechanged` initiated from clicking on a marker.. clicks.splice(index, 1); - } else { // nodechange initiated from the Mapillary viewer controls.. + // If `node.key` matches the current mapillaryImage, call `selectedImage()` + // one more time to update the detections and attribution.. + if (node.key === mapillaryImage) { + that.selectedImage(node.key, false); + } + } else { // `nodechanged` initiated from the Mapillary viewer controls.. var loc = node.computedLatLon ? [node.computedLatLon.lon, node.computedLatLon.lat] : [node.latLon.lon, node.latLon.lat]; context.map().centerEase(loc); that.selectedImage(node.key, false);