diff --git a/src/components/my-map/index.ts b/src/components/my-map/index.ts index f8254be..c2b9a68 100644 --- a/src/components/my-map/index.ts +++ b/src/components/my-map/index.ts @@ -129,6 +129,9 @@ export class MyMap extends LitElement { @property({ type: Number }) featureBuffer = 40; + @property({ type: Boolean }) + showNeighbourMarkers = false; + @property({ type: Boolean }) showMarker = false; @@ -587,14 +590,9 @@ export class MyMap extends LitElement { } }; - // show a marker at a point - if (this.showMarker) { + const showNewMarker = (lon, lat) => { 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({ @@ -604,6 +602,20 @@ export class MyMap extends LitElement { }); map.addLayer(markerLayer); + }; + + // show a marker at a point + if (this.showMarker) { + showNewMarker(this.markerLongitude, this.markerLatitude); + } + + if (this.showNeighbourMarkers) { + this.geojsonData.features.forEach((feature) => { + showNewMarker( + feature.geometry.coordinates[1], + feature.geometry.coordinates[0], + ); + }); } // XXX: force re-render for safari due to it thinking map is 0 height on load