LiveAtlas/src/leaflet/control/LinkControl.ts
2020-12-01 23:20:48 +00:00

27 lines
637 B
TypeScript

import L, {ControlOptions} from 'leaflet';
import {useStore} from "@/store";
export class LinkControl extends L.Control {
// @ts-ignore
options: ControlOptions
private _map ?: L.Map;
constructor(options: ControlOptions) {
super(options);
}
onAdd(map: L.Map) {
const linkButton = L.DomUtil.create('button', 'leaflet-control-link') as HTMLButtonElement;
linkButton.type = 'button';
linkButton.title = 'Link';
linkButton.addEventListener('click', () => {
const projection = useStore().state.currentProjection;
console.log(projection.latLngToLocation(this._map!.getCenter(), 64));
});
return linkButton;
}
}