mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 19:49:01 +01:00 
			
		
		
		
	feat(geomap): allow dragging
This commit is contained in:
		
							parent
							
								
									fed0598b47
								
							
						
					
					
						commit
						3281bb8e9f
					
				| @ -1,4 +1,4 @@ | |||||||
| import type { LatLng, LeafletMouseEvent } from "leaflet"; | import type { LatLng, LeafletMouseEvent, Marker } from "leaflet"; | ||||||
| import type FNote from "../../entities/fnote.js"; | import type FNote from "../../entities/fnote.js"; | ||||||
| import GeoMapWidget, { type InitCallback, type Leaflet } from "../geo_map.js"; | import GeoMapWidget, { type InitCallback, type Leaflet } from "../geo_map.js"; | ||||||
| import TypeWidget from "./type_widget.js" | import TypeWidget from "./type_widget.js" | ||||||
| @ -116,9 +116,14 @@ export default class GeoMapTypeWidget extends TypeWidget { | |||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             const [ lat, lng ] = latLng.split(",", 2).map((el) => parseFloat(el)); |             const [ lat, lng ] = latLng.split(",", 2).map((el) => parseFloat(el)); | ||||||
|             L.marker(L.latLng(lat, lng)) |             L.marker(L.latLng(lat, lng), { | ||||||
|  |                 draggable: true | ||||||
|  |             }) | ||||||
|                 .addTo(map) |                 .addTo(map) | ||||||
|                 .bindPopup(childNote.title); |                 .bindPopup(childNote.title) | ||||||
|  |                 .on("moveend", e => { | ||||||
|  |                     this.moveMarker(childNote.noteId, (e.target as Marker).getLatLng()); | ||||||
|  |                 }); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -131,12 +136,15 @@ export default class GeoMapTypeWidget extends TypeWidget { | |||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         const { noteId } = this.clipboard; |         this.moveMarker(this.clipboard.noteId, e.latlng); | ||||||
|         await attributes.setLabel(noteId, LOCATION_ATTRIBUTE, [e.latlng.lat, e.latlng.lng].join(",")); |  | ||||||
|         this.clipboard = undefined; |         this.clipboard = undefined; | ||||||
|         this.#adjustCursor(); |         this.#adjustCursor(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     async moveMarker(noteId: string, latLng: LatLng) { | ||||||
|  |         await attributes.setLabel(noteId, LOCATION_ATTRIBUTE, [latLng.lat, latLng.lng].join(",")); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     getData(): any { |     getData(): any { | ||||||
|         const map = this.geoMapWidget.map; |         const map = this.geoMapWidget.map; | ||||||
|         if (!map) { |         if (!map) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran