aboutsummaryrefslogtreecommitdiff
path: root/modern/src/map/notification/MapNotification.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/map/notification/MapNotification.js')
-rw-r--r--modern/src/map/notification/MapNotification.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/modern/src/map/notification/MapNotification.js b/modern/src/map/notification/MapNotification.js
new file mode 100644
index 00000000..5be80fac
--- /dev/null
+++ b/modern/src/map/notification/MapNotification.js
@@ -0,0 +1,38 @@
+import { useEffect } from 'react';
+import { map } from '../core/MapView';
+import './notification.css';
+
+class NotificationControl {
+ constructor(eventHandler) {
+ this.eventHandler = eventHandler;
+ }
+
+ onAdd() {
+ const button = document.createElement('button');
+ button.className = 'maplibregl-ctrl-icon maplibre-ctrl-notification';
+ button.type = 'button';
+ button.onclick = this.eventHandler;
+
+ this.container = document.createElement('div');
+ this.container.className = 'maplibregl-ctrl-group maplibregl-ctrl';
+ this.container.appendChild(button);
+
+ return this.container;
+ }
+
+ onRemove() {
+ this.container.parentNode.removeChild(this.container);
+ }
+}
+
+const MapNotification = () => {
+ useEffect(() => {
+ const control = new NotificationControl(() => {});
+ map.addControl(control);
+ return () => map.removeControl(control);
+ }, []);
+
+ return null;
+};
+
+export default MapNotification;