Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notification Control #299

Merged
merged 1 commit into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ de:
control:
geocoding: Standort-Suche
geolocation: Mein Standort
geolocation_notification_activated: "Geolocation activated"
geolocation_notification_deactivated: "Geolocation deactivated"
maximize: Zoom auf alle Objekte
upload: GeoJSON hochladen
fullscreen: Vollbildmodus umschalten
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ en:
control:
geocoding: "Location search"
geolocation: "My location"
geolocation_activated: "Geolocation activated"
geolocation_deactivated: "Geolocation deactivated"
maximize: "Zoom to all features"
upload: "Upload GeoJSON"
fullscreen: "Toggle full-screen"
Expand Down
2 changes: 2 additions & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ ja:
control:
geocoding: 住所検索
geolocation: 現在地へ移動
geolocation_notification_activated: "Geolocation activated"
geolocation_notification_deactivated: "Geolocation deactivated"
maximize: 地物にズーム
upload: GeoJSONのアップロード
fullscreen: フルスクリーン切り替え
Expand Down
16 changes: 15 additions & 1 deletion src/components/gtt-client/init/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Bar from 'ol-ext/control/Bar';
import Button from 'ol-ext/control/Button';
import LayerPopup from 'ol-ext/control/LayerPopup';
import LayerSwitcher from 'ol-ext/control/LayerSwitcher';
import Notification from 'ol-ext/control/Notification';
import { position } from 'ol-ext/control/control';

import { setGeocoding } from "../geocoding";
Expand Down Expand Up @@ -30,7 +31,7 @@ function addToolbarAndControls(instance: any): void {
*/
function addFullScreenAndRotateControls(instance: any): void {
instance.map.addControl(new FullScreen({
tipLabel: instance.i18n.control.fullscreen
tipLabel: instance.i18n.control.fullscreen,
}));

instance.map.addControl(new Rotate({
Expand Down Expand Up @@ -91,11 +92,24 @@ function addLayerSwitcherOrPopup(instance: any): void {
}
}

/**
* Adds notification control
* @param {any} instance
*/
function addNotificationControl(instance: any): void {
instance.map.notification = new Notification({
// closeBox: true,
// hideOnClick: true,
});
instance.map.addControl(instance.map.notification);
}

/**
* Initializes the controls for the GttClient instance.
* @this {any} - The GttClient instance.
*/
export function initControls(this: any): void {
addNotificationControl(this);
addToolbarAndControls(this);
addFullScreenAndRotateControls(this);
addMaximizeControl(this);
Expand Down
1 change: 1 addition & 0 deletions src/components/gtt-client/openlayers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ export function setGeolocation(currentMap: Map) {
onToggle: (active: boolean) => {
geolocation.setTracking(active)
geolocationLayer.setVisible(active)
this.map.notification.show((active ? this.i18n.control.geolocation_activated : this.i18n.control.geolocation_deactivated), 2000)
}
})
this.toolbar.addControl(geolocationCtrl)
Expand Down
Loading