Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions src/components/my-map/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
hexToRgba,
makeGeoJSON,
} from "./utils";
import { GeoJSONFeature } from "ol/format/GeoJSON";

type MarkerImageEnum = "circle" | "pin";
type ResetControlImageEnum = "unicode" | "trash";
Expand Down Expand Up @@ -130,7 +131,10 @@ export class MyMap extends LitElement {
featureBuffer = 40;

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

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

@property({ type: String })
markerImage: MarkerImageEnum = "circle";
Expand Down Expand Up @@ -587,14 +591,9 @@ export class MyMap extends LitElement {
}
};

// show a marker at a point
if (this.showMarker) {
const showNewMarker = (lon: number, lat: number) => {
const markerPoint = new Point(
transform(
[this.markerLongitude, this.markerLatitude],
projection,
"EPSG:3857",
),
transform([lon, lat], projection, "EPSG:3857"),
);
const markerLayer = new VectorLayer({
source: new VectorSource({
Expand All @@ -604,6 +603,20 @@ export class MyMap extends LitElement {
});

map.addLayer(markerLayer);
};

// show a marker at a point
if (this.showCentreMarker) {
showNewMarker(this.markerLongitude, this.markerLatitude);
}

if (this.showGeojsonDataMarkers) {
this.geojsonData.features.forEach((feature: GeoJSONFeature) => {
showNewMarker(
feature.geometry.coordinates[0],
feature.geometry.coordinates[1],
);
});
}

// XXX: force re-render for safari due to it thinking map is 0 height on load
Expand Down