support clicking on map to set specified geographic location

This commit is contained in:
MaysWind
2025-05-02 00:32:22 +08:00
parent 65a0e48988
commit 381d063295
23 changed files with 191 additions and 24 deletions
+16 -1
View File
@@ -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;