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