Przeglądaj źródła

hide the div icon at the back #56

tags/2.4.2
Caven Chen 4 lat temu
rodzic
commit
4acba6a667
2 zmienionych plików z 24 dodań i 20 usunięć
  1. 8
    10
      modules/layer/type/HtmlLayer.js
  2. 16
    10
      modules/overlay/html/DivIcon.js

+ 8
- 10
modules/layer/type/HtmlLayer.js Wyświetl plik

this.eachOverlay(item => { this.eachOverlay(item => {
if (item && item.position) { if (item && item.position) {
let position = Transform.transformWGS84ToCartesian(item.position) let position = Transform.transformWGS84ToCartesian(item.position)
let up = scene.globe.ellipsoid.geodeticSurfaceNormal(
position,
new Cesium.Cartesian3()
)
let windowCoord = Cesium.SceneTransforms.wgs84ToWindowCoordinates( let windowCoord = Cesium.SceneTransforms.wgs84ToWindowCoordinates(
scene, scene,
position position
) )
let up = scene.globe.ellipsoid.geodeticSurfaceNormal(
position,
new Cesium.Cartesian3()
item._updateStyle(
windowCoord,
Cesium.Cartesian3.distance(position, cp),
Cesium.Cartesian3.dot(cd, up) <= 0
) )

windowCoord &&
item._updateStyle(
{ transform: windowCoord },
Cesium.Cartesian3.distance(position, cp),
Cesium.Cartesian3.dot(cd, up) <= 0
)
} }
}, this) }, this)
}, this) }, this)

+ 16
- 10
modules/overlay/html/DivIcon.js Wyświetl plik



/** /**
* Updates style * Updates style
* @param style
* @param windowCoord
* @param distance * @param distance
* @param isFront * @param isFront
* @private * @private
*/ */
_updateStyle(style, distance, isFront) {
if (!this._show) {
_updateStyle(windowCoord, distance, isFront) {
if (!this._show || !windowCoord) {
return return
} }
let isDisplay = true
let translate3d = 'translate3d(0,0,0)'
if (style.transform) {
let x = style.transform.x - this._delegate.offsetWidth / 2
let y = style.transform.y - this._delegate.offsetHeight / 2
translate3d = `translate3d(${Math.round(x)}px,${Math.round(y)}px, 0)`
}
// set translate
let x = windowCoord.x - this._delegate.offsetWidth / 2
let y = windowCoord.y - this._delegate.offsetHeight / 2
let translate3d = `translate3d(${Math.round(x)}px,${Math.round(y)}px, 0)`
// set scale
let scale3d = 'scale3d(1,1,1)' let scale3d = 'scale3d(1,1,1)'
let scaleByDistance = this._style.scaleByDistance let scaleByDistance = this._style.scaleByDistance
if (distance && scaleByDistance) { if (distance && scaleByDistance) {
scale3d = `scale3d(${scale},${scale},1)` scale3d = `scale3d(${scale},${scale},1)`
} }
} }

// set condition
let isDisplay = true
let distanceDisplayCondition = this._style.distanceDisplayCondition let distanceDisplayCondition = this._style.distanceDisplayCondition
if (distance && distanceDisplayCondition) { if (distance && distanceDisplayCondition) {
isDisplay = isBetween( isDisplay = isBetween(
distanceDisplayCondition.far distanceDisplayCondition.far
) )
} }

// update style
this._delegate.style.transform = `${translate3d} ${scale3d}` this._delegate.style.transform = `${translate3d} ${scale3d}`
this._delegate.style.visibility = this._delegate.style.visibility =
isDisplay && isFront ? 'visible' : 'hidden' isDisplay && isFront ? 'visible' : 'hidden'
overlay: this, overlay: this,
position: Transform.transformWGS84ToCartesian(this._position) position: Transform.transformWGS84ToCartesian(this._position)
} }

this._delegate.addEventListener('click', () => { this._delegate.addEventListener('click', () => {
this._overlayEvent.fire(MouseEventType.CLICK, params) this._overlayEvent.fire(MouseEventType.CLICK, params)
}) })

Ładowanie…
Anuluj
Zapisz