Skip to content

Commit 2fef1b9

Browse files
committed
Adds notification box (fixes #166 )
Signed-off-by: Daniel Kastl <[email protected]>
1 parent c5cf1c8 commit 2fef1b9

File tree

6 files changed

+42
-9
lines changed

6 files changed

+42
-9
lines changed

config/locales/de.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ de:
8686
cancel: Abbrechen
8787
messages:
8888
baselayer_missing: "There is no baselayer available!"
89+
zoom_in_more: "Zoom in to view objects."
8990
gtt_map_rotate_label: Kartenrotation
9091
gtt_map_rotate_info_html: Hold down <code>Shift+Alt</code> and drag the map to rotate.
9192
gtt_settings_label_general: "General"

config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,4 @@ en:
110110
cancel: "Cancel"
111111
messages:
112112
baselayer_missing: "There is no baselayer available!"
113+
zoom_in_more: "Zoom in to view objects."

config/locales/ja.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,5 @@ ja:
109109
cancel: キャンセル
110110
messages:
111111
baselayer_missing: "There is no baselayer available!"
112+
zoom_in_more: "Zoom in to view objects."
112113
title_geojson_upload: GeoJSONのインポート

src/components/gtt-client/init/layers.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,34 @@ function addVectorLayer(this: any, features: Feature<Geometry>[] | null): void {
181181
});
182182
this.vector.set('title', 'Features');
183183
this.vector.set('displayInLayerSwitcher', false);
184+
185+
// Listen to the moveend event and show message when zoom level is too low
186+
let previousZoom = this.map.getView().getZoom();
187+
188+
const notification = document.createElement('div');
189+
notification.className = 'gtt-map-notification';
190+
notification.innerText = this.i18n.messages.zoom_in_more;
191+
192+
const mapContainer = this.map.getTargetElement();
193+
Object.assign(mapContainer.style, {
194+
position: 'relative',
195+
});
196+
197+
this.map.on('moveend', () => {
198+
const currentZoom = this.map.getView().getZoom();
199+
if (previousZoom !== currentZoom) {
200+
if (currentZoom <= Number(this.defaults.vectorMinzoom || 0)) {
201+
mapContainer.appendChild(notification);
202+
}
203+
else {
204+
try {
205+
mapContainer.removeChild(notification);
206+
} catch (error) {}
207+
}
208+
previousZoom = currentZoom;
209+
}
210+
});
211+
184212
this.map.addLayer(this.vector);
185213
}
186214

src/components/gtt-client/openlayers/index.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -318,23 +318,15 @@ export function setPopover() {
318318
*/
319319
export function setBasemap(): void {
320320
if (this.layerArray.length == 0) {
321-
console.warn(this.i18n.messages.baselayer_missing);
322-
323321
const notification = document.createElement('div');
322+
notification.className = 'gtt-map-notification';
324323
notification.innerText = this.i18n.messages.baselayer_missing;
325324

326325
const mapContainer = this.map.getTargetElement();
327326
Object.assign(mapContainer.style, {
328327
position: 'relative',
329328
});
330329

331-
Object.assign(notification.style, {
332-
position: 'absolute',
333-
top: '55%',
334-
left: '50%',
335-
transform: 'translate(-50%, -50%)',
336-
});
337-
338330
mapContainer.appendChild(notification);
339331
return
340332
}

src/styles/scss/app.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ div.ol-rotate {
9090
font-size: 1.5rem;
9191
}
9292

93+
.gtt-map-notification {
94+
background-color: #f1515c;
95+
color: #fff;
96+
padding: 0.5em;
97+
position: absolute;
98+
top: 55%;
99+
left: 50%;
100+
transform: translate(-50%, -50%);
101+
}
102+
93103
// map.png icon as data URI
94104
$data-uri: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAK2SURBVBgZBcHLjxN1AADg79eZttvddttll+WxIGrAV4QYTbxoYsSLgjc5arx68qCGf8G7J+NBEg8e9GqURDEmEiOJAWNUwIi8sryWDbSdmc60Mx2/Lxw78caZ1fXVo1EUAYAAACAIg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