Skip to content

Commit

Permalink
fix: ensure point features passed in via geojsonData has associated…
Browse files Browse the repository at this point in the history
… style (#482)
  • Loading branch information
jessicamcinchak authored Aug 29, 2024
1 parent 09c0ded commit f28222b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/components/my-map/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { html, LitElement, unsafeCSS } from "lit";
import { customElement, property } from "lit/decorators.js";
import apply from "ol-mapbox-style";
import { defaults as defaultControls, ScaleLine } from "ol/control";
import { FeatureLike } from "ol/Feature";
import { GeoJSON } from "ol/format";
import { GeoJSONFeature } from "ol/format/GeoJSON";
import { Point } from "ol/geom";
Expand Down Expand Up @@ -53,8 +54,8 @@ import {
import styles from "./styles.scss?inline";
import {
AreaUnitEnum,
fitToData,
calculateArea,
fitToData,
hexToRgba,
makeGeoJSON,
} from "./utils";
Expand Down Expand Up @@ -475,7 +476,7 @@ export class MyMap extends LitElement {

const geojsonLayer = new VectorLayer({
source: geojsonSource,
style: function (this: MyMap, feature: any) {
style: function (this: MyMap, feature: FeatureLike) {
// Read color from geojson feature `properties` if set or fallback to prop
let featureColor = feature.get("color") || this.geojsonColor;
return new Style({
Expand All @@ -488,6 +489,10 @@ export class MyMap extends LitElement {
? hexToRgba(featureColor, 0.2)
: hexToRgba(featureColor, 0),
}),
image: new Circle({
radius: 9,
fill: new Fill({ color: featureColor }),
}),
});
}.bind(this),
});
Expand Down

0 comments on commit f28222b

Please sign in to comment.