Skip to content

Commit

Permalink
Merge pull request #299 from gtt-project/dkastl/issue298
Browse files Browse the repository at this point in the history
Add notification Control.

Merging this, because I want to use the notification feature in some other places.
  • Loading branch information
dkastl authored Jun 2, 2024
2 parents 4cc0f75 + 3c74f76 commit 368c0e0
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
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 @@ -100,6 +100,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 @@ -100,6 +100,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 @@ -482,6 +482,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

0 comments on commit 368c0e0

Please sign in to comment.