mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 08:14:25 +08:00
support clicking on map to set specified geographic location
This commit is contained in:
+16
-1
@@ -1,8 +1,10 @@
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-nocheck
|
||||
import type { MapPosition } from '@/core/map.ts';
|
||||
|
||||
import { type LeafletTileSource, type LeafletTileSourceExtraParam, LEAFLET_TILE_SOURCES } from '@/consts/map.ts';
|
||||
|
||||
import type { MapProvider, MapInstance, MapInstanceInitOptions, MapPosition } from './base.ts';
|
||||
import type { MapProvider, MapInstance, MapInstanceInitOptions } from './base.ts';
|
||||
|
||||
import {
|
||||
isMapDataFetchProxyEnabled,
|
||||
@@ -35,6 +37,10 @@ export class LeafletMapProvider implements MapProvider {
|
||||
}
|
||||
}
|
||||
|
||||
public isSupportGetGeoLocationByClick(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
public asyncLoadAssets(language?: string): Promise<unknown> {
|
||||
return Promise.all([
|
||||
@@ -158,6 +164,15 @@ export class LeafletMapInstance implements MapInstance {
|
||||
this.leafletAttribution = attribution;
|
||||
}
|
||||
|
||||
leafletInstance.addEventListener('click', function(e) {
|
||||
if (options.onClick) {
|
||||
options.onClick({
|
||||
latitude: e.latlng.lat,
|
||||
longitude: e.latlng.lng
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.leafletInstance = leafletInstance;
|
||||
this.leafletTileLayer = tileLayer;
|
||||
this.leafletZoomControl = zoomControl;
|
||||
|
||||
Reference in New Issue
Block a user