Skip to content

Commit

Permalink
#465 Disable Globe more thoroughly when off (#466)
Browse files Browse the repository at this point in the history
  • Loading branch information
tariqksoliman authored Dec 12, 2023
1 parent 7f86c96 commit afaf31d
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 80 deletions.
8 changes: 5 additions & 3 deletions src/essence/Ancillary/QueryURL.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,11 @@ var QueryURL = {
if (mapZoom == undefined) mapZoom = L_.Map_.map.getZoom()

var globeCenter = L_.Globe_.litho.getCenter()
if (globeLon == undefined) globeLon = globeCenter.lng
if (globeLat == undefined) globeLat = globeCenter.lat
if (globeZoom == undefined) globeZoom = L_.Globe_.litho.zoom
if (globeCenter) {
if (globeLon == undefined) globeLon = globeCenter.lng
if (globeLat == undefined) globeLat = globeCenter.lat
if (globeZoom == undefined) globeZoom = L_.Globe_.litho.zoom
}

var viewerImg = L_.Viewer_.getLastImageId()
var viewerLoc = L_.Viewer_.getLocation()
Expand Down
27 changes: 27 additions & 0 deletions src/essence/Basics/Globe_/Globe_.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ let Globe_ = {
// CONSTRUCTOR
this.litho = new LithoSphere(containerId, lithoConfig)

if (!L_.hasGlobe) {
this.litho = this.getMockLitho(this.litho)
return
}

this.litho.addControl('mmgisLithoHome', this.litho.controls.home)
this.litho.addControl(
'mmgisLithoExaggerate',
Expand Down Expand Up @@ -199,6 +204,28 @@ let Globe_ = {
coordinates.hideElevation()
})
},
getMockLitho: function () {
return {
removeLayer: function () {},
addLayer: function () {},
toggleLayer: function () {},
hasLayer: function () {},
getCenter: function () {},
setCenter: function () {},
getCameras: function () {},
setLayerOpacity: function () {},
setLayerFilterEffect: function () {},
orderLayers: function () {},
invalidateSize: function () {},
setLayerSpecificOptions: function () {},
getElevationAtLngLat: function () {
return 0
},
projection: this.litho.projection,
_: {},
options: {},
}
},
reset: function () {},
setLink: function () {},
highlight: function () {},
Expand Down
22 changes: 12 additions & 10 deletions src/essence/Basics/Map_/Map_.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,16 +206,18 @@ let Map_ = {
$('.map-autoset-zoom').text(Map_.map.getZoom())
})

this.map.on('move', (e) => {
const c = this.map.getCenter()
Globe_.controls.link.linkMove(c.lng, c.lat)
})
this.map.on('mousemove', (e) => {
Globe_.controls.link.linkMouseMove(e.latlng.lng, e.latlng.lat)
})
this.map.on('mouseout', (e) => {
Globe_.controls.link.linkMouseOut()
})
if (Globe_.controls.link) {
this.map.on('move', (e) => {
const c = this.map.getCenter()
Globe_.controls.link.linkMove(c.lng, c.lat)
})
this.map.on('mousemove', (e) => {
Globe_.controls.link.linkMouseMove(e.latlng.lng, e.latlng.lat)
})
this.map.on('mouseout', (e) => {
Globe_.controls.link.linkMouseOut()
})
}

// Clear the selected feature if clicking on the map where there are no features
Map_.map.addEventListener('click', clearOnMapClick)
Expand Down
4 changes: 2 additions & 2 deletions src/essence/Basics/UserInterface_/BottomBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ let BottomBar = {
`</li>`,
`</ul>`,
`</div>`,
(L_.Globe_ ?
(L_.Globe_ && L_.hasGlobe ?
[`<div class='mainSettingsModalSection' id='mainSettingsModalSection3DGlobe'>`,
`<div class='mainSettingsModalSectionTitle'>3D Globe</div>`,
`<ul class='mainSettingsModalSectionOptions'>`,
Expand Down Expand Up @@ -555,7 +555,7 @@ let BottomBar = {
$(
'#mainSettingsModalSection3DGlobe #globeSetRadiusOfTiles'
).on('input', function () {
if (L_.Globe_) {
if (L_.Globe_ && L_.hasGlobe) {
L_.Globe_.litho.options.radiusOfTiles = parseInt(
$(this).val()
)
Expand Down
52 changes: 31 additions & 21 deletions src/essence/Tools/Identifier/IdentifierTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ var IdentifierTool = {
}, 5)
},
idPixelGlobe: function (e) {
IdentifierTool.idPixel(e, [
Globe_.litho.mouse.lng,
Globe_.litho.mouse.lat,
Globe_.litho.zoom,
])
if (Globe_.litho.mouse)
IdentifierTool.idPixel(e, [
Globe_.litho.mouse.lng,
Globe_.litho.mouse.lat,
Globe_.litho.zoom,
])
},
idValueMap: function (e) {
IdentifierTool.idPixel(
Expand All @@ -127,11 +128,16 @@ var IdentifierTool = {
)
},
idValueGlobe: function (e) {
IdentifierTool.idPixel(
e,
[Globe_.litho.mouse.lng, Globe_.litho.mouse.lat, Globe_.litho.zoom],
true
)
if (Globe_.litho.mouse)
IdentifierTool.idPixel(
e,
[
Globe_.litho.mouse.lng,
Globe_.litho.mouse.lat,
Globe_.litho.zoom,
],
true
)
},
//lnglatzoom is [lng,lat,zoom]
//if trueValue is true, query the data layer for the value, else us the legend if possible
Expand Down Expand Up @@ -418,26 +424,30 @@ function interfaceWithMMWebGIS() {
d3.select('#map').style('cursor', 'crosshair')

Map_.map.on('mousemove', IdentifierTool.idPixelMap)
Globe_.litho
.getContainer()
.addEventListener('mousemove', IdentifierTool.idPixelGlobe, false)
//Globe_.shouldRaycastSprites = false
if (L_.hasGlobe) {
Globe_.litho
.getContainer()
.addEventListener('mousemove', IdentifierTool.idPixelGlobe, false)
//Globe_.shouldRaycastSprites = false

Globe_.litho.getContainer().style.cursor = 'crosshair'
}

Globe_.litho.getContainer().style.cursor = 'crosshair'
//Share everything. Don't take things that aren't yours.
// Put things back where you found them.
function separateFromMMWebGIS() {
CursorInfo.hide()

d3.select('#map').style('cursor', previousCursor)

//Globe_.shouldRaycastSprites = true
Globe_.litho.getContainer().style.cursor = 'default'

Map_.map.off('mousemove', IdentifierTool.idPixelMap)
Globe_.litho
.getContainer()
.removeEventListener('mousemove', IdentifierTool.idPixelGlobe)
//Globe_.shouldRaycastSprites = true
if (L_.hasGlobe) {
Globe_.litho.getContainer().style.cursor = 'default'
Globe_.litho
.getContainer()
.removeEventListener('mousemove', IdentifierTool.idPixelGlobe)
}
}
}

Expand Down
110 changes: 66 additions & 44 deletions src/essence/Tools/Measure/MeasureTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import calls from '../../../pre/calls'

import metricsGraphics from '../../../external/MetricsGraphics/metricsgraphics.min'

import {render, unmountComponentAtNode } from 'react-dom'
import { render, unmountComponentAtNode } from 'react-dom'
import React, { useState, useEffect, useRef } from 'react'

import { Chart } from 'chart.js'
Expand Down Expand Up @@ -64,15 +64,25 @@ const Measure = () => {
.on('mousemove', MeasureTool.moveMap)
.on('mouseout', MeasureTool.mouseOutMap)

const globeCont = Globe_.litho.getContainer()
globeCont.addEventListener(
'mousedown',
MeasureTool.mouseDownGlobe,
false
)
globeCont.addEventListener('mouseup', MeasureTool.clickGlobe, false)
globeCont.addEventListener('mousemove', MeasureTool.moveGlobe, false)
globeCont.addEventListener('mouseout', MeasureTool.mouseOutMap, false)
if (L_.hasGlobe) {
const globeCont = Globe_.litho.getContainer()
globeCont.addEventListener(
'mousedown',
MeasureTool.mouseDownGlobe,
false
)
globeCont.addEventListener('mouseup', MeasureTool.clickGlobe, false)
globeCont.addEventListener(
'mousemove',
MeasureTool.moveGlobe,
false
)
globeCont.addEventListener(
'mouseout',
MeasureTool.mouseOutMap,
false
)
}

Viewer_.imageViewerMap.addHandler(
'canvas-click',
Expand Down Expand Up @@ -632,19 +642,29 @@ let MeasureTool = {
.off('mousemove', MeasureTool.moveMap)
.off('mouseout', MeasureTool.mouseOutMap)

const globeCont = Globe_.litho.getContainer()
globeCont.removeEventListener(
'mousedown',
MeasureTool.mouseDownGlobe,
false
)
globeCont.removeEventListener('mouseup', MeasureTool.clickGlobe, false)
globeCont.removeEventListener('mousemove', MeasureTool.moveGlobe, false)
globeCont.removeEventListener(
'mouseout',
MeasureTool.mouseOutMap,
false
)
if (L_.hasGlobe) {
const globeCont = Globe_.litho.getContainer()
globeCont.removeEventListener(
'mousedown',
MeasureTool.mouseDownGlobe,
false
)
globeCont.removeEventListener(
'mouseup',
MeasureTool.clickGlobe,
false
)
globeCont.removeEventListener(
'mousemove',
MeasureTool.moveGlobe,
false
)
globeCont.removeEventListener(
'mouseout',
MeasureTool.mouseOutMap,
false
)
}

Viewer_.imageViewerMap.removeHandler(
'canvas-click',
Expand Down Expand Up @@ -1539,28 +1559,30 @@ function makeGlobePolyline(polylinePoints) {
},
})
}

const globeBCR = Globe_.litho.getContainer()?.getBoundingClientRect() || {}
if (globeBCR.width > 0)
Globe_.litho.addLayer('clamped', {
name: '_measurePolyline',
id: '_measurePolyline',
on: true,
order: 10,
opacity: 1,
minZoom: 0,
maxZoom: 30,
style: {
default: {
weight: 3,
color: 'prop=color',
if (L_.hasGlobe) {
const globeBCR =
Globe_.litho.getContainer()?.getBoundingClientRect() || {}
if (globeBCR.width > 0)
Globe_.litho.addLayer('clamped', {
name: '_measurePolyline',
id: '_measurePolyline',
on: true,
order: 10,
opacity: 1,
minZoom: 0,
maxZoom: 30,
style: {
default: {
weight: 3,
color: 'prop=color',
},
},
},
geojson: {
type: 'FeatureCollection',
features: features,
},
})
geojson: {
type: 'FeatureCollection',
features: features,
},
})
}
}

MeasureTool.init()
Expand Down

0 comments on commit afaf31d

Please sign in to comment.