]> git.openstreetmap.org Git - nominatim-ui.git/blobdiff - src/components/Map.svelte
Convert current_result and current_request_latlon stores into simple variables ...
[nominatim-ui.git] / src / components / Map.svelte
index 2d1270d37b1695dd60812ec48a4896a6df469fc1..e9c4ceff1a898fc49c15c159ed562af03989d5b5 100644 (file)
@@ -7,10 +7,12 @@
 
   import { get } from 'svelte/store';
   import { get_config_value } from '../lib/config_reader.js';
-  import { map_store, current_result_store, current_request_latlon } from '../lib/stores.js';
+  import { map_store } from '../lib/stores.js';
   import MapPosition from '../components/MapPosition.svelte';
 
   export let display_minimap = false;
+  export let current_result = null;
+  export let position_marker = null;
 
   let dataLayers = [];
 
   function mapAction(container) {
     let map = createMap(container);
     map_store.set(map);
-    setMapData(get(current_result_store));
+    setMapData(current_result);
 
     return {
-      destroy: () => { map.remove(); }
+      destroy: () => {
+        map_store.set(null);
+        map.remove();
+      }
     };
   }
 
 
     resetMapData();
 
-    let request_latlon = get(current_request_latlon);
-    if (request_latlon) {
+    if (position_marker) {
       // We don't need a marker, but an L.circle instance changes radius once you zoom in/out
       let cm = L.circleMarker(
-        request_latlon,
+        position_marker,
         {
           radius: 5,
           weight: 2,
     }
   }
 
-  current_result_store.subscribe(aFeature => {
-    setMapData(aFeature);
-  });
-
+  $: setMapData(current_result);
 
   function show_map_position_click(e) {
     e.target.style.display = 'none';
     }
   }
 
-</style>
\ No newline at end of file
+</style>