Skip to content

Commit

Permalink
feat: showLabel prop added (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
RODO94 authored Oct 18, 2024
1 parent c663685 commit fcedda9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/components/my-map/drawing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function configureDrawingLayerStyle(
drawType: DrawTypeEnum,
drawColor: string,
drawMany: boolean,
hideDrawLabels: boolean,
feature: FeatureLike,
) {
drawColor = feature.get("color") || drawColor;
Expand All @@ -95,7 +96,10 @@ function configureDrawingLayerStyle(
radius: 12,
fill: new Fill({ color: drawColor }),
}),
text: drawMany ? styleFeatureLabels(drawType, feature) : undefined,
text:
drawMany && !hideDrawLabels
? styleFeatureLabels(drawType, feature)
: undefined,
});
default:
return [
Expand All @@ -107,7 +111,10 @@ function configureDrawingLayerStyle(
color: drawColor,
width: 3,
}),
text: drawMany ? styleFeatureLabels(drawType, feature) : undefined,
text:
drawMany && !hideDrawLabels
? styleFeatureLabels(drawType, feature)
: undefined,
}),
getVertices(drawColor),
];
Expand All @@ -120,11 +127,18 @@ export function configureDrawingLayer(
drawType: DrawTypeEnum,
drawColor: string,
drawMany: boolean,
hideDrawLabels: boolean,
) {
return new VectorLayer({
source: drawingSource,
style: function (feature) {
return configureDrawingLayerStyle(drawType, drawColor, drawMany, feature);
return configureDrawingLayerStyle(
drawType,
drawColor,
drawMany,
hideDrawLabels,
feature,
);
},
});
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/my-map/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ export class MyMap extends LitElement {
@property({ type: String })
areaUnit: AreaUnitEnum = "m2";

@property({ type: Boolean })
hideDrawLabels = false;

@property({ type: Boolean })
showScale = false;

Expand Down Expand Up @@ -526,6 +529,7 @@ export class MyMap extends LitElement {
this.drawType,
this.drawColor,
this.drawMany,
this.hideDrawLabels,
);
if (this.drawMode) {
// Clear drawingSource to begin, even if drawGeojsonData is provided
Expand Down

0 comments on commit fcedda9

Please sign in to comment.