Skip to content

Commit

Permalink
fix: some ts error
Browse files Browse the repository at this point in the history
  • Loading branch information
hongfaqiu committed Sep 6, 2024
1 parent 0d7b68a commit f9b33f6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/geojson-render/src/primitiveRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ export const primitiveGeoJsonRender = async (
}
break;
}
if (label?.paint.text) {
if (label?.paint.text && feature.center) {
primitiveLayer.addLabel({
type: 'Label',
position: feature.center?.cartesian3,
position: feature.center.cartesian3,
style: {
font: `bold 20px Arial`,
outlineWidth: 4,
Expand Down
6 changes: 4 additions & 2 deletions packages/primitive-geojson/src/GeoJsonPrimitiveLayer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ArcType,
Billboard,
BillboardCollection,
BlendOption,
BlendingState,
Expand All @@ -10,6 +11,7 @@ import {
DeveloperError,
Event,
GeometryInstance,
Label,
LabelCollection,
PerInstanceColorAppearance,
PinBuilder,
Expand Down Expand Up @@ -253,8 +255,8 @@ export class GeoJsonPrimitiveLayer extends BasicGraphicLayer {
const id = this._generateId();
const instance = this._billboardCollection.add({
id,
...(style as Billboard.ConstructorOptions),
position,
...style,
});
this.addFeatureItem({
...item,
Expand All @@ -270,8 +272,8 @@ export class GeoJsonPrimitiveLayer extends BasicGraphicLayer {
const id = this._generateId();
const instance = this._labelCollection.add({
id,
...(style as Label.ConstructorOptions),
position,
...style,
});
return instance;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/primitive-geojson/src/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export type BillboardPrimitiveItem = {

export type LabelPrimitiveItem = {
type: 'Label';
position?: Cartesian3;
position: Cartesian3;
style?: LabelGraphics.ConstructorOptions;
instance?: Label;
} & GeoJsonFeatureItem;
Expand Down

0 comments on commit f9b33f6

Please sign in to comment.