From 3d2bdabb60a032509b5701c80a9fca2c4656060a Mon Sep 17 00:00:00 2001 From: mtmail Date: Thu, 8 Apr 2021 17:12:21 +0200 Subject: [PATCH] when navigating search to reverse page, keep the map position (#114) --- src/components/Header.svelte | 16 ++++++++++++++-- src/components/MapPosition.svelte | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/components/Header.svelte b/src/components/Header.svelte index 9fef1f9..514fe20 100644 --- a/src/components/Header.svelte +++ b/src/components/Header.svelte @@ -4,10 +4,22 @@ import LastUpdated from './LastUpdated.svelte'; import Error from './Error.svelte'; - import { page } from '../lib/stores.js'; + import { map_store, page } from '../lib/stores.js'; $: view = $page.tab; $: page_title = Nominatim_Config.Page_Title; + + let map_lat; + let map_lon; + + map_store.subscribe(map => { + if (!map) return; + + map.on('move', function () { + map_lat = map.getCenter().lat; + map_lon = map.getCenter().lng; + }); + });