mirror of
https://github.com/ccmdi/obsidian-map-plus.git
synced 2026-07-22 06:43:14 +00:00
feat: 'open in web' and 'set as center'
This commit is contained in:
parent
4d452ea1fd
commit
c9c6cf77ae
2 changed files with 24 additions and 0 deletions
|
|
@ -67,6 +67,7 @@ export interface MapRendererOptions {
|
|||
autoCenter?: boolean;
|
||||
onMarkerClick?: (point: MapPoint, event: MjolnirEvent) => void;
|
||||
onTilesLoaded?: () => void;
|
||||
onSetMapCenter?: (lat: number, lng: number) => void;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -735,6 +736,26 @@ export function createMapRenderer(config: MapRendererOptions): Deck<MapViewType[
|
|||
});
|
||||
});
|
||||
|
||||
if (options.onSetMapCenter) {
|
||||
menu.addItem((item) => {
|
||||
item
|
||||
.setTitle('Set as map center')
|
||||
.setIcon('map-pin')
|
||||
.onClick(() => {
|
||||
options.onSetMapCenter?.(lat, lng);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
menu.addItem((item) => {
|
||||
item
|
||||
.setTitle('Open in web')
|
||||
.setIcon('globe')
|
||||
.onClick(() => {
|
||||
window.open(`https://www.google.com/maps?q=${lat.toFixed(6)},${lng.toFixed(6)}`, '_blank');
|
||||
});
|
||||
});
|
||||
|
||||
menu.showAtMouseEvent(e);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -287,6 +287,9 @@ export class MapBasesView extends BasesView {
|
|||
onTilesLoaded: () => {
|
||||
tilesLoaded = true;
|
||||
hideOverlay();
|
||||
},
|
||||
onSetMapCenter: (lat: number, lng: number) => {
|
||||
this.config.set('center', `${lat}, ${lng}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue