Skip to content

Commit e714617

Browse files
author
潘卓然Y7000P
committed
【SDK】【修改】【针对Cesium的飞行高亮功能增加自定义颜色的功能】
1 parent af3dd98 commit e714617

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

src/cesiumjs/manager/PopupController.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,16 @@ export default class PopupController extends BaseLayer {
8181
if (containDiv === null || containDiv === undefined) {
8282
containDiv = document.createElement('div');
8383
containDiv.id = 'popup';
84+
document.body.appendChild(containDiv);
8485
}
8586
const randID = CommonFuncManager.generateRandom();
8687
const rootContentDiv = document.createElement('div');
8788
rootContentDiv.setAttribute('id', `popup_${randID}`);
88-
rootContentDiv.setAttribute('class', 'leaflet-popup');
89+
rootContentDiv.setAttribute('class', 'cesium-popup');
8990
rootContentDiv.setAttribute('style', 'top:5px;left:0;');
9091
const closeDiv = document.createElement('a');
91-
closeDiv.setAttribute('class', 'leaflet-popup-close-button');
92-
closeDiv.setAttribute('href', '#');
92+
closeDiv.setAttribute('class', 'cesium-popup-close-button');
93+
// closeDiv.setAttribute('href', '#');
9394
closeDiv.innerHTML = '×';
9495
const webControl = this;
9596
if (typeof closeCallback === 'function') {
@@ -100,18 +101,18 @@ export default class PopupController extends BaseLayer {
100101
rootContentDiv.appendChild(closeDiv);
101102

102103
const contentDiv = document.createElement('div');
103-
contentDiv.setAttribute('class', 'leaflet-popup-content-wrapper');
104+
contentDiv.setAttribute('class', 'cesium-popup-content-wrapper');
104105
const contentLinkDiv = document.createElement('div');
105-
contentLinkDiv.setAttribute('class', 'leaflet-popup-content');
106+
contentLinkDiv.setAttribute('class', 'cesium-popup-content');
106107
contentLinkDiv.setAttribute('style', 'max-width: 300px;');
107108
contentLinkDiv.innerHTML = content;
108109
contentDiv.appendChild(contentLinkDiv);
109110
rootContentDiv.appendChild(contentDiv);
110111

111112
const tipContainDiv = document.createElement('div');
112-
tipContainDiv.setAttribute('class', 'leaflet-popup-tip-container');
113+
tipContainDiv.setAttribute('class', 'cesium-popup-tip-container');
113114
const tipDiv = document.createElement('div');
114-
tipDiv.setAttribute('class', 'leaflet-popup-tip');
115+
tipDiv.setAttribute('class', 'cesium-popup-tip');
115116
tipContainDiv.appendChild(tipDiv);
116117
rootContentDiv.appendChild(tipContainDiv);
117118

@@ -262,16 +263,14 @@ export default class PopupController extends BaseLayer {
262263
removePopup(popID, popupOwner, options) {
263264
const owner = Cesium.defaultValue(popupOwner, this);
264265
const popDiv = document.getElementById(popID);
266+
const op = Cesium.defaultValue(options, {});
265267
if (popDiv === null || popDiv === undefined) {
266268
return;
267269
}
268270
while (popDiv.hasChildNodes()) {
269271
popDiv.removeChild(popDiv.firstChild);
270272
}
271-
let removeDiv = false;
272-
if (Cesium.defined(options.removeDiv)) {
273-
removeDiv = options.removeDiv;
274-
}
273+
const removeDiv = Cesium.defaultValue(op.removeDiv, false);
275274
if (removeDiv && popDiv.parentNode !== null) {
276275
popDiv.parentNode.removeChild(popDiv);
277276
}

src/cesiumjs/manager/SceneManager.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ export default class SceneManager {
418418
* @param {Array<layer>} layerList 图层列表
419419
* @param {Array<id>} id ID列表
420420
* @param {Object} [options] 其他参数
421+
* @param {Color} [options.colorHighlight] 跳转后指定ID对应的特定要素的高亮颜色
421422
* @param {Number} [options.heading] 相机参数heading
422423
* @param {Number} [options.pitch] 相机参数pitch
423424
* @param {Number} [options.range] 相机参数range
@@ -430,6 +431,7 @@ export default class SceneManager {
430431
const optionsParam = Cesium.defaultValue(options, {});
431432
const that = this;
432433
let first = true;
434+
const colorHighlight = Cesium.defaultValue(optionsParam.colorHighlight, undefined);
433435
function flyToF(feature) {
434436
const maxPoint = feature.getProperty('maxPoint');
435437
const minPoint = feature.getProperty('minPoint');
@@ -446,24 +448,23 @@ export default class SceneManager {
446448
that.viewer.camera.flyToBoundingSphere(boundingSphere, {
447449
offset: Cesium.defaultValue(optionsParam.offset, new Cesium.HeadingPitchRange(heading, pitch, range))
448450
});
449-
for (let i = 0; i < layerList.length; i += 1) {
450-
const tileset = layerList[i];
451-
tileset.style = undefined;
452-
tileset.styleEngine.justSelect(false, true);
453-
}
454451
first = false;
455452
}
456453

457454
function evaluateColorCallBack(feature) {
455+
const featureSpec = feature;
458456
if (first) {
459-
const title = feature.getProperty('name');
457+
const title = featureSpec.getProperty('name');
460458
const values = title.split('_');
461459
const vlueNumber = parseInt(values[2], 10);
462460
if (vlueNumber === id && first) {
463-
flyToF(feature);
461+
flyToF(featureSpec);
462+
if (colorHighlight !== undefined) {
463+
featureSpec.color = colorHighlight.clone();
464+
}
464465
}
465466
}
466-
return feature.color;
467+
return featureSpec.color;
467468
}
468469

469470
for (let i = 0; i < layerList.length; i += 1) {

0 commit comments

Comments
 (0)