Skip to content

Commit

Permalink
Show neighbouring properties as points on map
Browse files Browse the repository at this point in the history
Creates a property showNeighbourMark which when switched on creates
a marker for each point passed in on the geojsonData property.

This will be useful in BOPS as it can be difficult to know when drawing
a polygon whether you have selected the neighbouring properties. BOPS
will pass the coordinates of the neighbours via the geojsonData prop.
  • Loading branch information
cdccollins committed Jan 24, 2024
1 parent c237a53 commit feb6642
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/components/my-map/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ export class MyMap extends LitElement {
@property({ type: Number })
featureBuffer = 40;

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

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

Expand Down Expand Up @@ -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({
Expand All @@ -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
Expand Down

0 comments on commit feb6642

Please sign in to comment.