From 66b8d0934bc8a71ac42686ec2979e8fd26554151 Mon Sep 17 00:00:00 2001 From: Daniel Kastl Date: Wed, 5 Jun 2024 13:18:57 +0900 Subject: [PATCH] Handle message for platforms and geometry Signed-off-by: Daniel Kastl --- config/locales/de.yml | 2 ++ config/locales/en.yml | 2 ++ config/locales/ja.yml | 2 ++ src/components/gtt-client/helpers/platforms.ts | 17 +++++++++++++++++ src/components/gtt-client/openlayers/index.ts | 16 +++++++++++++++- 5 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/components/gtt-client/helpers/platforms.ts diff --git a/config/locales/de.yml b/config/locales/de.yml index 0651952..92ffb4c 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -83,6 +83,8 @@ de: baselayer_missing: "Es ist kein Baselayer verfügbar!" zoom_in_more: "Zoomen Sie hinein, um die Objekte zu sehen." modify_start: "Hold down ALT and click on a vertex to delete it." + modify_start_mac: "Hold down Option and click on a vertex to delete it." + modify_start_touch: "Tap on a vertex to delete it." gtt_map_rotate_label: Kartenrotation gtt_map_rotate_info_html: Halten Sie Shift+Alt gedrückt und ziehen Sie die Karte, um sie zu drehen. diff --git a/config/locales/en.yml b/config/locales/en.yml index 1108368..fe22c99 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -132,3 +132,5 @@ en: baselayer_missing: "There is no baselayer available!" zoom_in_more: "Zoom in to view objects." modify_start: "Hold down ALT and click on a vertex to delete it." + modify_start_mac: "Hold down Option and click on a vertex to delete it." + modify_start_touch: "Tap on a vertex to delete it." diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 18240c2..b6789da 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -127,3 +127,5 @@ ja: baselayer_missing: "背景レイヤーが存在しません!" zoom_in_more: "地物表示のためズームします。" modify_start: "Hold down ALT and click on a vertex to delete it." + modify_start_mac: "Hold down Option and click on a vertex to delete it." + modify_start_touch: "Tap on a vertex to delete it." diff --git a/src/components/gtt-client/helpers/platforms.ts b/src/components/gtt-client/helpers/platforms.ts new file mode 100644 index 0000000..f0cdd12 --- /dev/null +++ b/src/components/gtt-client/helpers/platforms.ts @@ -0,0 +1,17 @@ +/** + * Utility function to detect touch devices + * @param isTouchDevice - boolean + * @returns boolean + */ +export const isTouchDevice = (): boolean => { + return ('ontouchstart' in window) || (navigator.maxTouchPoints > 0); +} + +/** + * Utility function to detect macOS + * @param isMacOS - boolean + * @returns boolean + */ +export const isMacOS = (): boolean => { + return /Macintosh|MacIntel|MacPPC|Mac68K/.test(navigator.userAgent); +} diff --git a/src/components/gtt-client/openlayers/index.ts b/src/components/gtt-client/openlayers/index.ts index bbb53c6..c6fe69f 100644 --- a/src/components/gtt-client/openlayers/index.ts +++ b/src/components/gtt-client/openlayers/index.ts @@ -17,6 +17,7 @@ import { position } from 'ol-ext/control/control'; import { GeoJSON } from 'ol/format'; import { getCookie, getMapSize, degreesToRadians, updateForm, formatLength, formatArea } from "../helpers"; +import { isTouchDevice, isMacOS } from "../helpers/platforms"; // Define the types for the Tooltip and the custom methods you added interface ExtendedTooltip extends Tooltip { @@ -305,7 +306,20 @@ export function setControls(types: Array) { interaction.setActive(false); } }); - this.map.notification.show(this.i18n.messages.modify_start); + + if (this.vector.getSource().getFeatures().length > 0) { + const firstFeature = this.vector.getSource().getFeatures()[0]; + if (firstFeature && firstFeature.getGeometry().getType() !== 'Point') { + // Code to execute if the first feature is not a Point + let message = this.i18n.messages.modify_start; + if (isTouchDevice()) { + message = this.i18n.messages.modify_start_touch; + } else if (isMacOS()) { + message = this.i18n.messages.modify_start_mac; + } + this.map.notification.show(message); + } + } } else { modify.setActive(false); }