Skip to content

Commit

Permalink
solve the problem that some overlay setting labels are invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
cavencj committed Jan 8, 2022
1 parent 1472f38 commit d88fcd3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions modules/overlay/vector/Circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ class Circle extends Overlay {
this.center = this._center
}

/**
* Sets Text with Style
* @param text
* @param textStyle
* @returns {Circle}
*/
setLabel(text, textStyle) {
this._delegate.position = Transform.transformWGS84ToCartesian(this._center)
this._delegate.label = {
...textStyle,
text: text
}
return this
}

/**
*
* @param style
Expand Down
10 changes: 10 additions & 0 deletions modules/overlay/vector/Rectangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ class Rectangle extends Overlay {
* @returns {Rectangle}
*/
setLabel(text, textStyle) {
this._delegate.position = Cesium.Cartographic.toCartesian(
Cesium.Rectangle.center(
this._delegate.rectangle,
new Cesium.Cartographic()
)
)
this._delegate.label = {
...textStyle,
text: text
}
return this
}

Expand Down

0 comments on commit d88fcd3

Please sign in to comment.