diff --git a/src/essence/Basics/Layers_/Layers_.js b/src/essence/Basics/Layers_/Layers_.js index 2bd89028..4cc9e09d 100644 --- a/src/essence/Basics/Layers_/Layers_.js +++ b/src/essence/Basics/Layers_/Layers_.js @@ -3267,6 +3267,98 @@ const L_ = { } return features }, + propertiesToImages(props, baseUrl) { + baseUrl = baseUrl || '' + var images = [] + //Use "images" key first + if (props.hasOwnProperty('images')) { + for (var i = 0; i < props.images.length; i++) { + if (props.images[i].url) { + var url = baseUrl + props.images[i].url + if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url + if (props.images[i].isModel) { + images.push({ + url: url, + texture: props.images[i].texture, + name: + (props.images[i].name || + props.images[i].url.match( + /([^\/]*)\/*$/ + )[1]) + ' [Model]', + type: 'model', + isPanoramic: false, + isModel: true, + values: props.images[i].values || {}, + master: props.images[i].master, + }) + } else { + if (props.images[i].isPanoramic) { + images.push({ + ...props.images[i], + url: url, + name: + (props.images[i].name || + props.images[i].url.match( + /([^\/]*)\/*$/ + )[1]) + ' [Panoramic]', + type: 'photosphere', + isPanoramic: true, + isModel: false, + values: props.images[i].values || {}, + master: props.images[i].master, + }) + } + images.push({ + url: url, + name: + props.images[i].name || + props.images[i].url.match(/([^\/]*)\/*$/)[1], + type: props.images[i].type || 'image', + isPanoramic: false, + isModel: false, + values: props.images[i].values || {}, + master: props.images[i].master, + }) + } + } + } + } + //If there isn't one, search all string valued props for image urls + else { + for (var p in props) { + if ( + typeof props[p] === 'string' && + props[p].toLowerCase().match(/\.(jpeg|jpg|gif|png|xml)$/) != + null + ) { + var url = props[p] + if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url + images.push({ + url: url, + name: p, + isPanoramic: false, + isModel: false, + }) + } + if ( + typeof props[p] === 'string' && + (props[p].toLowerCase().match(/\.(obj)$/) != null || + props[p].toLowerCase().match(/\.(dae)$/) != null) + ) { + var url = props[p] + if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url + images.push({ + url: url, + name: p, + isPanoramic: false, + isModel: true, + }) + } + } + } + + return images + }, } //Takes in a configData object and does a depth-first search through its diff --git a/src/essence/Basics/Map_/Map_.js b/src/essence/Basics/Map_/Map_.js index baddd1e3..23146016 100644 --- a/src/essence/Basics/Map_/Map_.js +++ b/src/essence/Basics/Map_/Map_.js @@ -698,19 +698,13 @@ function featureDefaultClick(feature, layer, e) { } function keepGoing() { - //View images - var propImages = propertiesToImages( - feature.properties, - layer.options.metadata ? layer.options.metadata.base_url || '' : '' - ) - Kinds.use( L_.layers.data[layer.options.layerName].kind, Map_, feature, layer, layer.options.layerName, - propImages, + null, e ) @@ -724,13 +718,7 @@ function featureDefaultClick(feature, layer, e) { } } - Viewer_.changeImages(propImages, feature, layer) - for (var i in propImages) { - if (propImages[i].type == 'radargram') { - //Globe_.radargram( layer.options.layerName, feature.geometry, propImages[i].url, propImages[i].length, propImages[i].depth ); - break - } - } + Viewer_.changeImages(feature, layer) //figure out how to construct searchStr in URL. For example: a ChemCam target can sometime //be searched by "target sol", or it can be searched by "sol target" depending on config file. @@ -1191,98 +1179,6 @@ function allLayersLoaded() { } } -function propertiesToImages(props, baseUrl) { - baseUrl = baseUrl || '' - var images = [] - //Use "images" key first - if (props.hasOwnProperty('images')) { - for (var i = 0; i < props.images.length; i++) { - if (props.images[i].url) { - var url = baseUrl + props.images[i].url - if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url - if (props.images[i].isModel) { - images.push({ - url: url, - texture: props.images[i].texture, - name: - (props.images[i].name || - props.images[i].url.match(/([^\/]*)\/*$/)[1]) + - ' [Model]', - type: 'model', - isPanoramic: false, - isModel: true, - values: props.images[i].values || {}, - master: props.images[i].master, - }) - } else { - if (props.images[i].isPanoramic) { - images.push({ - ...props.images[i], - url: url, - name: - (props.images[i].name || - props.images[i].url.match( - /([^\/]*)\/*$/ - )[1]) + ' [Panoramic]', - type: 'photosphere', - isPanoramic: true, - isModel: false, - values: props.images[i].values || {}, - master: props.images[i].master, - }) - } - images.push({ - url: url, - name: - props.images[i].name || - props.images[i].url.match(/([^\/]*)\/*$/)[1], - type: props.images[i].type || 'image', - isPanoramic: false, - isModel: false, - values: props.images[i].values || {}, - master: props.images[i].master, - }) - } - } - } - } - //If there isn't one, search all string valued props for image urls - else { - for (var p in props) { - if ( - typeof props[p] === 'string' && - props[p].toLowerCase().match(/\.(jpeg|jpg|gif|png|xml)$/) != - null - ) { - var url = props[p] - if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url - images.push({ - url: url, - name: p, - isPanoramic: false, - isModel: false, - }) - } - if ( - typeof props[p] === 'string' && - (props[p].toLowerCase().match(/\.(obj)$/) != null || - props[p].toLowerCase().match(/\.(dae)$/) != null) - ) { - var url = props[p] - if (!F_.isUrlAbsolute(url)) url = L_.missionPath + url - images.push({ - url: url, - name: p, - isPanoramic: false, - isModel: true, - }) - } - } - } - - return images -} - function buildToolBar() { d3.select('#mapToolBar').html('') diff --git a/src/essence/Basics/Viewer_/PDFViewer.js b/src/essence/Basics/Viewer_/PDFViewer.js index 987c0e78..e5391563 100644 --- a/src/essence/Basics/Viewer_/PDFViewer.js +++ b/src/essence/Basics/Viewer_/PDFViewer.js @@ -52,7 +52,7 @@ const ReactPDF = (props) => { style={{ position: 'fixed', top: '40px', - left: '46px', + left: bcr ? `${bcr.left + 6}px` : '46px', display: 'flex', height: '30px', justifyContent: 'center', diff --git a/src/essence/Basics/Viewer_/Viewer_.js b/src/essence/Basics/Viewer_/Viewer_.js index d1a90cbf..128cf598 100644 --- a/src/essence/Basics/Viewer_/Viewer_.js +++ b/src/essence/Basics/Viewer_/Viewer_.js @@ -168,7 +168,12 @@ var Viewer_ = { }, //images is [ { 'url': '', 'name': '', 'isPanoramic': false },{...}, ... ] //Shows the first image too - changeImages: function (images, feature, layer) { + changeImages: function (feature, layer) { + let images = L_.propertiesToImages( + feature.properties, + layer.options.metadata ? layer.options.metadata.base_url || '' : '' + ) + // Don't refresh if the same exact point is clicked, // that's just annoying. So skip over it. if ( diff --git a/src/essence/Tools/Draw/DrawTool.js b/src/essence/Tools/Draw/DrawTool.js index 68ab5002..8adb4486 100644 --- a/src/essence/Tools/Draw/DrawTool.js +++ b/src/essence/Tools/Draw/DrawTool.js @@ -741,6 +741,7 @@ var DrawTool = { d ) + Viewer_.changeImages(layer.feature, layer) Globe_.highlight( Globe_.findSpriteObject( layer.options.layerName, diff --git a/src/essence/Tools/Draw/DrawTool_Editing.js b/src/essence/Tools/Draw/DrawTool_Editing.js index b23e8837..4ff4ac87 100644 --- a/src/essence/Tools/Draw/DrawTool_Editing.js +++ b/src/essence/Tools/Draw/DrawTool_Editing.js @@ -4,6 +4,7 @@ import L_ from '../../Basics/Layers_/Layers_' import LayerGeologic from '../../Basics/Layers_/LayerGeologic/LayerGeologic' import Globe_ from '../../Basics/Globe_/Globe_' import Map_ from '../../Basics/Map_/Map_' +import Viewer_ from '../../Basics/Viewer_/Viewer_' import UserInterface_ from '../../Basics/UserInterface_/UserInterface_' import CursorInfo from '../../Ancillary/CursorInfo' import turf from 'turf' @@ -2770,6 +2771,11 @@ var Editing = { } return newProperties } + + Viewer_.changeImages( + DrawTool.contextMenuLayer.feature, + DrawTool.contextMenuLayer + ) }, getSnapGuides: function (layer) { var guides = []