Skip to content

Commit

Permalink
Handle message for platforms and geometry
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kastl <daniel@georepublic.de>
  • Loading branch information
dkastl committed Jun 5, 2024
1 parent de01a9d commit 66b8d09
Show file tree
Hide file tree
Showing 5 changed files with 38 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 @@ -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 <code>ALT</code> and click on a vertex to delete it."
modify_start_mac: "Hold down <code>Option</code> 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 <code>Shift+Alt</code> gedrückt und ziehen
Sie die Karte, um sie zu drehen.
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,5 @@ en:
baselayer_missing: "There is no baselayer available!"
zoom_in_more: "Zoom in to view objects."
modify_start: "Hold down <code>ALT</code> and click on a vertex to delete it."
modify_start_mac: "Hold down <code>Option</code> and click on a vertex to delete it."
modify_start_touch: "Tap on a vertex to delete it."
2 changes: 2 additions & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,5 @@ ja:
baselayer_missing: "背景レイヤーが存在しません!"
zoom_in_more: "地物表示のためズームします。"
modify_start: "Hold down <code>ALT</code> and click on a vertex to delete it."
modify_start_mac: "Hold down <code>Option</code> and click on a vertex to delete it."
modify_start_touch: "Tap on a vertex to delete it."
17 changes: 17 additions & 0 deletions src/components/gtt-client/helpers/platforms.ts
Original file line number Diff line number Diff line change
@@ -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);
}
16 changes: 15 additions & 1 deletion src/components/gtt-client/openlayers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -305,7 +306,20 @@ export function setControls(types: Array<string>) {
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);
}
Expand Down

0 comments on commit 66b8d09

Please sign in to comment.