aboutsummaryrefslogtreecommitdiff
path: root/modern/src/map/notification/MapNotification.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-07-03 07:43:27 -0700
committerAnton Tananaev <anton@traccar.org>2022-07-03 07:43:27 -0700
commit0ab655eb5c031e1a2aac18ef475aff6c7724b227 (patch)
tree26ef43ebdfb703378cc44807273ff5dfd63ee1db /modern/src/map/notification/MapNotification.js
parent44fd230a4c0043a6e89a793bcf333072a01441a6 (diff)
downloadtrackermap-web-0ab655eb5c031e1a2aac18ef475aff6c7724b227.tar.gz
trackermap-web-0ab655eb5c031e1a2aac18ef475aff6c7724b227.tar.bz2
trackermap-web-0ab655eb5c031e1a2aac18ef475aff6c7724b227.zip
Add events button
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;