forked from MapComplete/MapComplete
		
	Fix: precise location input picks correct location (and not the previous click)
This commit is contained in:
		
							parent
							
								
									b2a10e7af9
								
							
						
					
					
						commit
						6d337e8775
					
				
					 1 changed files with 13 additions and 15 deletions
				
			
		|  | @ -13,11 +13,6 @@ import { Utils } from "../../../Utils" | ||||||
| export class LastClickFeatureSource implements WritableFeatureSource { | export class LastClickFeatureSource implements WritableFeatureSource { | ||||||
|     public readonly features: UIEventSource<Feature[]> = new UIEventSource<Feature[]>([]) |     public readonly features: UIEventSource<Feature[]> = new UIEventSource<Feature[]>([]) | ||||||
| 
 | 
 | ||||||
|     /** |  | ||||||
|      * Must be public: passed as tags into the selected view |  | ||||||
|      */ |  | ||||||
|     public properties: Record<string, string> |  | ||||||
| 
 |  | ||||||
|     constructor(location: Store<{ lon: number; lat: number }>, layout: LayoutConfig) { |     constructor(location: Store<{ lon: number; lat: number }>, layout: LayoutConfig) { | ||||||
|         const allPresets: BaseUIElement[] = [] |         const allPresets: BaseUIElement[] = [] | ||||||
|         for (const layer of layout.layers) |         for (const layer of layout.layers) | ||||||
|  | @ -37,17 +32,20 @@ export class LastClickFeatureSource implements WritableFeatureSource { | ||||||
|             ) |             ) | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|  |         let i = 0 | ||||||
|  | 
 | ||||||
|  |         location.addCallbackAndRunD(({ lon, lat }) => { | ||||||
|             const properties = { |             const properties = { | ||||||
|                 lastclick: "yes", |                 lastclick: "yes", | ||||||
|             id: "last_click", |                 id: "last_click_" + i, | ||||||
|                 has_note_layer: layout.layers.some((l) => l.id === "note") ? "yes" : "no", |                 has_note_layer: layout.layers.some((l) => l.id === "note") ? "yes" : "no", | ||||||
|                 has_presets: layout.layers.some((l) => l.presets?.length > 0) ? "yes" : "no", |                 has_presets: layout.layers.some((l) => l.presets?.length > 0) ? "yes" : "no", | ||||||
|                 renderings: renderings.join(""), |                 renderings: renderings.join(""), | ||||||
|                 number_of_presets: "" + renderings.length, |                 number_of_presets: "" + renderings.length, | ||||||
|                 first_preset: renderings[0], |                 first_preset: renderings[0], | ||||||
|             } |             } | ||||||
|         this.properties = properties |             i++ | ||||||
|         location.addCallbackAndRunD(({ lon, lat }) => { | 
 | ||||||
|             const point = <Feature<Point>>{ |             const point = <Feature<Point>>{ | ||||||
|                 type: "Feature", |                 type: "Feature", | ||||||
|                 properties, |                 properties, | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue