mapcomplete/UI/BigComponents/RightControls.ts

43 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-07-28 16:48:59 +02:00
import Combine from "../Base/Combine";
import Toggle from "../Input/Toggle";
import MapControlButton from "../MapControlButton";
import GeoLocationHandler from "../../Logic/Actors/GeoLocationHandler";
import Svg from "../../Svg";
import MapState from "../../Logic/State/MapState";
2021-07-28 16:48:59 +02:00
export default class RightControls extends Combine {
constructor(state:MapState) {
2021-07-28 16:48:59 +02:00
const geolocationButton = new Toggle(
new MapControlButton(
new GeoLocationHandler(
state.currentGPSLocation,
state.leafletMap,
state.layoutToUse
2021-07-28 16:48:59 +02:00
), {
dontStyle: true
}
),
undefined,
state.featureSwitchGeolocation
2021-07-28 16:48:59 +02:00
);
const plus = new MapControlButton(
2021-08-20 00:06:44 +02:00
Svg.plus_svg()
2021-07-28 16:48:59 +02:00
).onClick(() => {
state.locationControl.data.zoom++;
state.locationControl.ping();
2021-07-28 16:48:59 +02:00
});
const min = new MapControlButton(
2021-08-20 00:06:44 +02:00
Svg.min_svg()
2021-07-28 16:48:59 +02:00
).onClick(() => {
state.locationControl.data.zoom--;
state.locationControl.ping();
2021-07-28 16:48:59 +02:00
});
super([plus, min, geolocationButton].map(el => el.SetClass("m-0.5 md:m-1")))
this.SetClass("flex flex-col items-center")
2021-07-28 16:48:59 +02:00
}
}