From 0ab655eb5c031e1a2aac18ef475aff6c7724b227 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 3 Jul 2022 07:43:27 -0700 Subject: Add events button --- modern/src/map/notification/MapNotification.js | 38 ++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 modern/src/map/notification/MapNotification.js (limited to 'modern/src/map/notification/MapNotification.js') 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; -- cgit v1.2.3