@lblod/ember-rdfa-editor-lblod-plugins 35.1.1 → 35.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @lblod/ember-rdfa-editor-lblod-plugins
2
2
 
3
+ ## 35.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#634](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/pull/634) [`7f89a0f`](https://github.com/lblod/ember-rdfa-editor-lblod-plugins/commit/7f89a0f010d4f843407390621cdab4f0966deb02) Thanks [@kobemertens](https://github.com/kobemertens)! - Change the default tile server of location plugin to GBR and add OSM as an option
8
+
3
9
  ## 35.1.1
4
10
 
5
11
  ### Patch Changes
@@ -20,6 +20,10 @@ import {
20
20
  GeoPos,
21
21
  type GlobalCoordinates,
22
22
  } from '@lblod/ember-rdfa-editor-lblod-plugins/plugins/location-plugin/utils/geo-helpers';
23
+ import AuToggleSwitch from '@appuniversum/ember-appuniversum/components/au-toggle-switch';
24
+ import AuCard from '@appuniversum/ember-appuniversum/components/au-card';
25
+ import { on } from '@ember/modifier';
26
+ import set from '@lblod/ember-rdfa-editor-lblod-plugins/helpers/set';
23
27
 
24
28
  // Taken from Leaflet's default icon, with the viewbox tweaked (from 0 0 500 820), so that the icon
25
29
  // is a whole number of pixels in size, to make positioning the point easy.
@@ -56,16 +60,26 @@ const MARKER_ICON = Leaflet.divIcon({
56
60
  export const SUPPORTED_LOCATION_TYPES = ['address', 'place', 'area'] as const;
57
61
  export type LocationType = (typeof SUPPORTED_LOCATION_TYPES)[number];
58
62
 
59
- const MAP_TILE_ATTRIBUTION =
60
- '&copy; <a target="_blank" href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
61
- const MAP_TILE_URL = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
63
+ const TILE_PROVIDER_CONSTANTS = {
64
+ OPEN_STREET_MAP: {
65
+ ATTRIBUTION:
66
+ '&copy; <a target="_blank" href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
67
+ URL: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
68
+ },
69
+ GRB: {
70
+ ATTRIBUTION:
71
+ 'Bron: Grootschalig Referentie Bestand Vlaanderen, Digitaal Vlaanderen',
72
+ URL: 'https://geo.api.vlaanderen.be/GRB/wmts?layer=grb_bsk&style=GRB-Basiskaart&tilematrixset=GoogleMapsVL&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png&TileMatrix={z}&TileCol={x}&TileRow={y}',
73
+ },
74
+ };
75
+
62
76
  const COORD_SYSTEM_CENTER: GlobalCoordinates = {
63
77
  lng: 4.450822554431,
64
78
  lat: 50.50526730529,
65
79
  };
66
80
  const COORD_SYSTEM_START = {
67
81
  center: COORD_SYSTEM_CENTER,
68
- zoom: 7,
82
+ zoom: 8,
69
83
  };
70
84
 
71
85
  function isLast(array: unknown[], index: number) {
@@ -216,6 +230,7 @@ class MapWrapper extends Component<MapWrapperSig> {
216
230
 
217
231
  export default class LocationPluginMapComponent extends Component<Signature> {
218
232
  @tracked vertices: GlobalCoordinates[] = [];
233
+ @tracked useOpenStreetMaps = false;
219
234
 
220
235
  // Use untracked properties as otherwise the map jumps to any area or location we pick
221
236
  existingAreaBounds = generateBoundsFromShape(this.args.existingArea);
@@ -259,6 +274,14 @@ export default class LocationPluginMapComponent extends Component<Signature> {
259
274
  return 'center' in this.mapLocation ? this.mapLocation.center : false;
260
275
  }
261
276
 
277
+ get tileProvider() {
278
+ if (this.useOpenStreetMaps) {
279
+ return TILE_PROVIDER_CONSTANTS.OPEN_STREET_MAP;
280
+ } else {
281
+ return TILE_PROVIDER_CONSTANTS.GRB;
282
+ }
283
+ }
284
+
262
285
  @action
263
286
  onMapClick(event: LeafletMouseEvent) {
264
287
  if (this.args.locationType === 'place') {
@@ -280,6 +303,11 @@ export default class LocationPluginMapComponent extends Component<Signature> {
280
303
  }
281
304
  }
282
305
 
306
+ @action
307
+ stopEventPropagation(event: MouseEvent) {
308
+ event.stopPropagation();
309
+ }
310
+
283
311
  <template>
284
312
  <div
285
313
  class='map-wrapper
@@ -291,10 +319,46 @@ export default class LocationPluginMapComponent extends Component<Signature> {
291
319
  @onClick={{this.onMapClick}}
292
320
  as |layers|
293
321
  >
294
- <layers.tile
295
- @url={{MAP_TILE_URL}}
296
- @attribution={{MAP_TILE_ATTRIBUTION}}
297
- />
322
+ <div
323
+ {{! template-lint-disable no-invalid-interactive }}
324
+ {{on 'click' this.stopEventPropagation}}
325
+ class='tile-provider-selector'
326
+ >
327
+ <AuCard
328
+ class='au-u-padding-tiny'
329
+ @size='flush'
330
+ @textCenter={{true}}
331
+ as |c|
332
+ >
333
+ <c.content>
334
+ <AuToggleSwitch @onChange={{set this 'useOpenStreetMaps'}}>
335
+ <p class='au-u-para-tiny'>{{t
336
+ 'location-plugin.use-open-street-map'
337
+ }}</p>
338
+ </AuToggleSwitch>
339
+ </c.content>
340
+ </AuCard>
341
+ </div>
342
+ {{! Don't change: I know the last component from each leg can be lifted out of the condition but cycling the OSM button does not work anymore then}}
343
+ {{#if (eq this.tileProvider.URL TILE_PROVIDER_CONSTANTS.GRB.URL)}}
344
+ <layers.tile
345
+ @url={{TILE_PROVIDER_CONSTANTS.OPEN_STREET_MAP.URL}}
346
+ @minZoom={{8}}
347
+ @maxNativeZoom={{12}}
348
+ />
349
+ <layers.tile
350
+ @url={{this.tileProvider.URL}}
351
+ @attribution={{this.tileProvider.ATTRIBUTION}}
352
+ @minZoom={{8}}
353
+ />
354
+ {{else}}
355
+ <layers.tile
356
+ @url={{this.tileProvider.URL}}
357
+ @attribution={{this.tileProvider.ATTRIBUTION}}
358
+ @minZoom={{8}}
359
+ />
360
+ {{/if}}
361
+
298
362
  {{#if (and @address (eq @locationType 'address') this.foundAddress)}}
299
363
  <layers.marker
300
364
  @location={{this.foundAddress}}
@@ -0,0 +1,15 @@
1
+ export default <T extends string, U>(
2
+ obj: Record<T, U>,
3
+ propName: T,
4
+ value?: U,
5
+ ) => {
6
+ if (value === undefined) {
7
+ return (innerValue: U) => {
8
+ obj[propName] = innerValue;
9
+ };
10
+ } else {
11
+ return () => {
12
+ obj[propName] = value;
13
+ };
14
+ }
15
+ };
@@ -19,6 +19,7 @@
19
19
 
20
20
  .map-wrapper {
21
21
  height: 100%;
22
+ position: relative;
22
23
  }
23
24
 
24
25
  // Override the 'grab' cursor to 'pointer' so we can accurately pick points
@@ -28,5 +29,13 @@
28
29
 
29
30
  .leaflet-container {
30
31
  height: 100%;
32
+ font-family: var(--au-font);
33
+ }
34
+
35
+ .leaflet-container .tile-provider-selector {
36
+ position: absolute;
37
+ bottom: 0.6em;
38
+ left: 0.6em;
39
+ z-index: 1000;
31
40
  }
32
41
  }
@@ -20,11 +20,17 @@ interface Signature {
20
20
  }
21
21
  export default class LocationPluginMapComponent extends Component<Signature> {
22
22
  vertices: GlobalCoordinates[];
23
+ useOpenStreetMaps: boolean;
23
24
  existingAreaBounds: LatLngBoundsExpression | undefined;
24
25
  existingLocationCoords: GlobalCoordinates | undefined;
25
26
  mapLocation: LeafletMapStart;
26
27
  get foundAddress(): false | import("leaflet").LatLngTuple | import("leaflet").LatLngLiteral;
28
+ get tileProvider(): {
29
+ ATTRIBUTION: string;
30
+ URL: string;
31
+ };
27
32
  onMapClick(event: LeafletMouseEvent): void;
28
33
  onVertexClick(index: number): void;
34
+ stopEventPropagation(event: MouseEvent): void;
29
35
  }
30
36
  export {};
@@ -0,0 +1,2 @@
1
+ declare const _default: <T extends string, U>(obj: Record<T, U>, propName: T, value?: U) => (innerValue: U) => void;
2
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lblod/ember-rdfa-editor-lblod-plugins",
3
- "version": "35.1.1",
3
+ "version": "35.1.2",
4
4
  "description": "Ember addon providing lblod specific plugins for the ember-rdfa-editor",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -434,6 +434,7 @@ lmb-plugin:
434
434
 
435
435
  location-plugin:
436
436
  insert-placeholder: Insert location placeholder
437
+ use-open-street-map: OpenStreetMap
437
438
  modal:
438
439
  insert: Insert location
439
440
  edit: Edit location
@@ -431,6 +431,7 @@ lmb-plugin:
431
431
 
432
432
  location-plugin:
433
433
  insert-placeholder: Voeg locatie-placeholder in
434
+ use-open-street-map: OpenStreetMap
434
435
  modal:
435
436
  insert: Locatie invoegen
436
437
  edit: Bewerk locatie