Skip to content

Commit 216b913

Browse files
Add longpress
1 parent 95d2417 commit 216b913

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/components/MapPin.svelte

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@
77
88
const { map } = getOlContext()
99
10-
map.on('click', async (e) => {
10+
const LONG_PRESS_THRESHOLD = 500;
11+
12+
let mouseDownAt: number;
13+
map.getTargetElement().addEventListener('mousedown', e => {
14+
mouseDownAt = Date.now();
15+
});
16+
17+
map.on('singleclick', async (e) => {
18+
const pressDuration = Date.now() - mouseDownAt
19+
if (pressDuration < LONG_PRESS_THRESHOLD) {
20+
return
21+
}
22+
1123
const [lng, lat] = toLonLat(e.coordinate)
1224
const closestPoint = await findPlace(lat, lng)
1325
$fragment.label = {

src/layers/layerDefinitions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const layerDefinitions: TileLayerDefinition[] = [
5656
}
5757
},
5858
{
59-
name: "Hillshade",
59+
name: "Hill shade",
6060
description: "Terrain relief overlay",
6161
type: 'overlay',
6262
defaultVisible: true,

0 commit comments

Comments
 (0)