forked from MapComplete/MapComplete
		
	Feature(geocoding): pressing enter will now zoom to the first search result; refactor away type synonym
This commit is contained in:
		
							parent
							
								
									9e8aaab086
								
							
						
					
					
						commit
						686ad70511
					
				
					 8 changed files with 64 additions and 49 deletions
				
			
		|  | @ -5,17 +5,14 @@ | |||
|   import LayerConfig from "../../Models/ThemeConfig/LayerConfig" | ||||
|   import { UIEventSource } from "../../Logic/UIEventSource" | ||||
|   import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig" | ||||
|   import { createEventDispatcher } from "svelte" | ||||
|   import type { SpecialVisualizationState } from "../SpecialVisualization" | ||||
|   import { BBox } from "../../Logic/BBox" | ||||
|   import ToSvelte from "../Base/ToSvelte.svelte" | ||||
|   import Icon from "../Map/Icon.svelte" | ||||
|   import TagRenderingAnswer from "../Popup/TagRendering/TagRenderingAnswer.svelte" | ||||
|   import ArrowUp from "@babeard/svelte-heroicons/mini/ArrowUp" | ||||
|   import DefaultIcon from "../Map/DefaultIcon.svelte" | ||||
|   import { WithSearchState } from "../../Models/ThemeViewState/WithSearchState" | ||||
| 
 | ||||
|   export let entry: GeocodeResult | ||||
|   export let state: SpecialVisualizationState | ||||
|   export let state: WithSearchState | ||||
| 
 | ||||
|   let layer: LayerConfig | ||||
|   let tags: UIEventSource<Record<string, string>> | ||||
|  | @ -36,34 +33,15 @@ | |||
|   let inView = state.mapProperties.bounds.mapD((bounds) => bounds.contains([entry.lon, entry.lat])) | ||||
| 
 | ||||
|   function select() { | ||||
|     if (entry.boundingbox) { | ||||
|       const [lat0, lat1, lon0, lon1] = entry.boundingbox | ||||
|       state.mapProperties.bounds.set( | ||||
|         new BBox([ | ||||
|           [lon0, lat0], | ||||
|           [lon1, lat1], | ||||
|         ]).pad(0.01) | ||||
|       ) | ||||
|     } else { | ||||
|       state.mapProperties.flyTo( | ||||
|         entry.lon, | ||||
|         entry.lat, | ||||
|         GeocodingUtils.categoryToZoomLevel[entry.category] ?? 17 | ||||
|       ) | ||||
|     } | ||||
|     if (entry.feature?.properties?.id) { | ||||
|       state.selectedElement.set(entry.feature) | ||||
|     } | ||||
|     state.userRelatedState.recentlyVisitedSearch.add(entry) | ||||
|     state.searchState.closeIfFullscreen() | ||||
|     state.searchState.applyGeocodeResult(entry) | ||||
|   } | ||||
| </script> | ||||
| 
 | ||||
| <button class="unstyled link-no-underline searchresult w-full" on:click={() => select()}> | ||||
|   <div class="flex w-full items-center gap-y-2 p-2"> | ||||
|     {#if layer} | ||||
|       <div class="h-6"> | ||||
|         <DefaultIcon {layer} properties={entry.feature.properties} clss="w-6 h-6" /> | ||||
|       <div class="h-6 w-6"> | ||||
|         <DefaultIcon {layer} properties={entry.feature.properties} /> | ||||
|       </div> | ||||
|     {:else if entry.category} | ||||
|       <Icon | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue