@geolonia/embed 5.0.0 → 5.0.3

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.
Files changed (40) hide show
  1. package/.github/workflows/build.yml +16 -14
  2. package/.nvmrc +1 -1
  3. package/.prettierrc.json +4 -0
  4. package/.tool-versions +1 -1
  5. package/README.md +7 -1
  6. package/dist/embed +1 -1
  7. package/dist/embed-chunks/2489af4328c51b71e92d.js +2 -0
  8. package/dist/embed-chunks/6e05bbf5f391fda5b858.js +1 -0
  9. package/dist/embed.js +1 -1
  10. package/dist/src/embed.d.ts +3 -1
  11. package/dist/src/lib/geolonia-map.d.ts +1 -2
  12. package/dist/src/lib/geolonia-marker.d.ts +1 -2
  13. package/dist/src/lib/util.d.ts +1 -0
  14. package/dist/src/version.d.ts +1 -1
  15. package/e2e/map.spec.ts +1 -1
  16. package/eslint.config.js +232 -0
  17. package/package.json +20 -11
  18. package/src/embed.ts +13 -7
  19. package/src/lib/CustomAttributionControl.ts +52 -29
  20. package/src/lib/geolonia-map.ts +126 -39
  21. package/src/lib/geolonia-marker.ts +9 -6
  22. package/src/lib/keyring.test.ts +18 -0
  23. package/src/lib/keyring.ts +11 -13
  24. package/src/lib/maplibre-util.ts +31 -19
  25. package/src/lib/parse-atts.test.ts +3 -4
  26. package/src/lib/parse-atts.ts +1 -1
  27. package/src/lib/render.ts +18 -7
  28. package/src/lib/simplestyle-vector.ts +42 -13
  29. package/src/lib/simplestyle.test.ts +80 -69
  30. package/src/lib/simplestyle.ts +55 -34
  31. package/src/lib/util.test.ts +71 -22
  32. package/src/lib/util.ts +88 -32
  33. package/src/testability.test.ts +7 -4
  34. package/webpack.config.js +10 -1
  35. package/.eslintignore +0 -3
  36. package/.eslintrc.js +0 -17
  37. package/.prettierrc.js +0 -1
  38. package/dist/embed-chunks/416af3373e37004e65f4.js +0 -1
  39. package/dist/embed-chunks/488aacb380a87ea633f6.js +0 -2
  40. /package/dist/embed-chunks/{488aacb380a87ea633f6.js.LICENSE.txt → 2489af4328c51b71e92d.js.LICENSE.txt} +0 -0
@@ -19,21 +19,30 @@ class SimpleStyleVector {
19
19
  addTo(map) {
20
20
  const container = map.getContainer();
21
21
 
22
- if (!container.dataset || (!container.dataset.lng && !container.dataset.lat)) {
22
+ if (
23
+ !container.dataset ||
24
+ (!container.dataset.lng && !container.dataset.lat)
25
+ ) {
23
26
  let initialZoomDone = false;
24
27
  map.on('sourcedata', (event) => {
25
28
  // skip events for sources that don't concern us
26
- if (event.sourceId !== this.sourceName) { return; }
29
+ if (event.sourceId !== this.sourceName) {
30
+ return;
31
+ }
27
32
 
28
33
  const source = map.getSource(event.sourceId);
29
34
  // query the map to see if the source is actually loaded or not. We can't trust `isSourceLoaded` in the event
30
35
  // because it's unreliable and often incorrect.
31
36
  const isLoaded = source && source.loaded();
32
37
 
33
- if (isLoaded !== true) { return; }
38
+ if (isLoaded !== true) {
39
+ return;
40
+ }
34
41
 
35
42
  // Only zoom once.
36
- if (initialZoomDone) { return; }
43
+ if (initialZoomDone) {
44
+ return;
45
+ }
37
46
  initialZoomDone = true;
38
47
 
39
48
  map.fitBounds(source.bounds, {
@@ -59,7 +68,11 @@ class SimpleStyleVector {
59
68
  filter: ['==', '$type', 'Polygon'],
60
69
  paint: {
61
70
  'text-color': ['string', ['get', 'text-color'], textColor],
62
- 'text-halo-color': ['string', ['get', 'text-halo-color'], textHaloColor],
71
+ 'text-halo-color': [
72
+ 'string',
73
+ ['get', 'text-halo-color'],
74
+ textHaloColor,
75
+ ],
63
76
  'text-halo-width': 1,
64
77
  },
65
78
  layout: {
@@ -79,7 +92,11 @@ class SimpleStyleVector {
79
92
  filter: ['==', '$type', 'LineString'],
80
93
  paint: {
81
94
  'text-color': ['string', ['get', 'text-color'], textColor],
82
- 'text-halo-color': ['string', ['get', 'text-halo-color'], textHaloColor],
95
+ 'text-halo-color': [
96
+ 'string',
97
+ ['get', 'text-halo-color'],
98
+ textHaloColor,
99
+ ],
83
100
  'text-halo-width': 1,
84
101
  },
85
102
  layout: {
@@ -158,8 +175,10 @@ class SimpleStyleVector {
158
175
  paint: {
159
176
  'circle-radius': [
160
177
  'case',
161
- ['==', 'small', ['get', 'marker-size']], 7,
162
- ['==', 'large', ['get', 'marker-size']], 13,
178
+ ['==', 'small', ['get', 'marker-size']],
179
+ 7,
180
+ ['==', 'large', ['get', 'marker-size']],
181
+ 13,
163
182
  9,
164
183
  ],
165
184
  'circle-color': ['string', ['get', 'marker-color'], backgroundColor],
@@ -178,7 +197,11 @@ class SimpleStyleVector {
178
197
  filter: ['==', '$type', 'Point'],
179
198
  paint: {
180
199
  'text-color': ['string', ['get', 'text-color'], textColor],
181
- 'text-halo-color': ['string', ['get', 'text-halo-color'], textHaloColor],
200
+ 'text-halo-color': [
201
+ 'string',
202
+ ['get', 'text-halo-color'],
203
+ textHaloColor,
204
+ ],
182
205
  'text-halo-width': 1,
183
206
  },
184
207
  layout: {
@@ -190,8 +213,10 @@ class SimpleStyleVector {
190
213
  'text-max-width': 12,
191
214
  'text-offset': [
192
215
  'case',
193
- ['==', 'small', ['get', 'marker-size']], ['literal', [0, 1]],
194
- ['==', 'large', ['get', 'marker-size']], ['literal', [0, 1.6]],
216
+ ['==', 'small', ['get', 'marker-size']],
217
+ ['literal', [0, 1]],
218
+ ['==', 'large', ['get', 'marker-size']],
219
+ ['literal', [0, 1.6]],
195
220
  ['literal', [0, 1.2]],
196
221
  ],
197
222
  'text-allow-overlap': false,
@@ -204,12 +229,16 @@ class SimpleStyleVector {
204
229
 
205
230
  async setPopup(map, source) {
206
231
  map.on('click', source, async (e) => {
207
- const center: [ number, number ] = turfCenter(e.features[0]).geometry.coordinates as [ number, number ];
232
+ const center: [number, number] = turfCenter(e.features[0]).geometry
233
+ .coordinates as [number, number];
208
234
  const description = e.features[0].properties.description;
209
235
 
210
236
  if (description) {
211
237
  const sanitizedDescription = await sanitizeDescription(description);
212
- new maplibregl.Popup().setLngLat(center).setHTML(sanitizedDescription).addTo(map);
238
+ new maplibregl.Popup()
239
+ .setLngLat(center)
240
+ .setHTML(sanitizedDescription)
241
+ .addTo(map);
213
242
  }
214
243
  });
215
244
 
@@ -17,7 +17,10 @@ class Map {
17
17
  public layers = [];
18
18
  public sources = {};
19
19
 
20
- constructor(private json?, private options?) {}
20
+ constructor(
21
+ private json?,
22
+ private options?,
23
+ ) {}
21
24
 
22
25
  addSource(id, source) {
23
26
  this.sources[id] = source;
@@ -27,13 +30,14 @@ class Map {
27
30
  this.layers.push(layer);
28
31
  }
29
32
 
30
- on() {
31
-
32
- }
33
+ on() {}
33
34
 
34
35
  getSource(id) {
35
36
  class getSource {
36
- constructor(private id, private sources) {}
37
+ constructor(
38
+ private id,
39
+ private sources,
40
+ ) {}
37
41
  setData(geojson) {
38
42
  this.sources[this.id] = {
39
43
  type: 'geojson',
@@ -56,17 +60,14 @@ class Map {
56
60
  }
57
61
 
58
62
  const geojson = {
59
- 'type': 'FeatureCollection',
60
- 'features': [
63
+ type: 'FeatureCollection',
64
+ features: [
61
65
  {
62
- 'type': 'Feature',
63
- 'properties': {},
64
- 'geometry': {
65
- 'type': 'Point',
66
- 'coordinates': [
67
- 139.77012634277344,
68
- 35.68518697509636,
69
- ],
66
+ type: 'Feature',
67
+ properties: {},
68
+ geometry: {
69
+ type: 'Point',
70
+ coordinates: [139.77012634277344, 35.68518697509636],
70
71
  },
71
72
  },
72
73
  ],
@@ -79,20 +80,36 @@ describe('Tests for simpleStyle()', () => {
79
80
  const map = new Map();
80
81
  new SimpleStyle(geojson).addTo(map).fitBounds();
81
82
 
82
- assert.deepEqual([ 'geolonia-simple-style', 'geolonia-simple-style-points' ], Object.keys(map.sources));
83
+ assert.deepEqual(
84
+ ['geolonia-simple-style', 'geolonia-simple-style-points'],
85
+ Object.keys(map.sources),
86
+ );
83
87
  assert.deepEqual(8, map.layers.length);
84
88
  assert.deepEqual(true, map.bounds);
85
- assert.deepEqual(true, map.layers.find((layer) => layer.id === 'geolonia-simple-style-symbol-points').layout['icon-allow-overlap']);
86
- assert.deepEqual(true, map.layers.find((layer) => layer.id === 'geolonia-simple-style-symbol-points').layout['text-allow-overlap']);
89
+ assert.deepEqual(
90
+ true,
91
+ map.layers.find(
92
+ (layer) => layer.id === 'geolonia-simple-style-symbol-points',
93
+ ).layout['icon-allow-overlap'],
94
+ );
95
+ assert.deepEqual(
96
+ true,
97
+ map.layers.find(
98
+ (layer) => layer.id === 'geolonia-simple-style-symbol-points',
99
+ ).layout['text-allow-overlap'],
100
+ );
87
101
  });
88
102
 
89
103
  it('should has sources and layers as expected with custom IDs', async () => {
90
104
  const { SimpleStyle } = await import('./simplestyle');
91
105
 
92
106
  const map = new Map();
93
- new SimpleStyle(geojson, {id: 'hello-world'}).addTo(map).fitBounds();
107
+ new SimpleStyle(geojson, { id: 'hello-world' }).addTo(map).fitBounds();
94
108
 
95
- assert.deepEqual([ 'hello-world', 'hello-world-points' ], Object.keys(map.sources));
109
+ assert.deepEqual(
110
+ ['hello-world', 'hello-world-points'],
111
+ Object.keys(map.sources),
112
+ );
96
113
  assert.deepEqual(8, map.layers.length);
97
114
  assert.deepEqual(true, map.bounds);
98
115
  });
@@ -103,13 +120,16 @@ describe('Tests for simpleStyle()', () => {
103
120
  const map = new Map();
104
121
 
105
122
  const empty = {
106
- 'type': 'FeatureCollection',
107
- 'features': [],
123
+ type: 'FeatureCollection',
124
+ features: [],
108
125
  };
109
126
 
110
- new SimpleStyle(empty, {id: 'hello-world'}).addTo(map).fitBounds();
127
+ new SimpleStyle(empty, { id: 'hello-world' }).addTo(map).fitBounds();
111
128
 
112
- assert.deepEqual([ 'hello-world', 'hello-world-points' ], Object.keys(map.sources));
129
+ assert.deepEqual(
130
+ ['hello-world', 'hello-world-points'],
131
+ Object.keys(map.sources),
132
+ );
113
133
  assert.deepEqual(8, map.layers.length);
114
134
  assert.deepEqual(false, map.bounds);
115
135
  });
@@ -120,53 +140,52 @@ describe('Tests for simpleStyle()', () => {
120
140
  const map = new Map();
121
141
 
122
142
  const empty = {
123
- 'type': 'FeatureCollection',
124
- 'features': [],
143
+ type: 'FeatureCollection',
144
+ features: [],
125
145
  };
126
146
 
127
147
  const ss = new SimpleStyle(empty).addTo(map).fitBounds();
128
148
 
129
- assert.deepEqual([ 'geolonia-simple-style', 'geolonia-simple-style-points' ], Object.keys(map.sources));
149
+ assert.deepEqual(
150
+ ['geolonia-simple-style', 'geolonia-simple-style-points'],
151
+ Object.keys(map.sources),
152
+ );
130
153
  assert.deepEqual(8, map.layers.length);
131
154
  assert.deepEqual(false, map.bounds);
132
- assert.deepEqual(0, map.sources['geolonia-simple-style-points'].data.features.length);
155
+ assert.deepEqual(
156
+ 0,
157
+ map.sources['geolonia-simple-style-points'].data.features.length,
158
+ );
133
159
 
134
160
  ss.updateData(geojson); // The GeoJSON is not empty.
135
161
  assert.deepEqual(false, map.bounds); // `fitBounds()` doesn't fire.
136
- assert.deepEqual(1, map.sources['geolonia-simple-style-points'].data.features.length);
162
+ assert.deepEqual(
163
+ 1,
164
+ map.sources['geolonia-simple-style-points'].data.features.length,
165
+ );
137
166
  });
138
167
 
139
168
  it('should load GeoJSON from url', async () => {
140
169
  const { SimpleStyle } = await import('./simplestyle');
141
170
 
142
171
  const map = new Map();
143
- const geojson = 'https://gist.githubusercontent.com/miya0001/56c3dc174f5cdf1d9565cbca0fbd3c48/raw/c13330036d28ef547a8a87cb6df3fa12de19ddb6/test.geojson';
172
+ const geojson =
173
+ 'https://gist.githubusercontent.com/miya0001/56c3dc174f5cdf1d9565cbca0fbd3c48/raw/c13330036d28ef547a8a87cb6df3fa12de19ddb6/test.geojson';
144
174
  const ss = new SimpleStyle(geojson);
145
175
  ss.addTo(map).fitBounds();
146
176
 
147
177
  await ss._loadingPromise;
148
178
 
149
- const geometry = map.sources['geolonia-simple-style'].data.features[0].geometry;
179
+ const geometry =
180
+ map.sources['geolonia-simple-style'].data.features[0].geometry;
150
181
  const coordinates = geometry.coordinates;
151
182
  const type = geometry.type;
152
183
 
153
184
  const expectCoordinates = [
154
- [
155
- 139.6870422363281,
156
- 35.73425097869431,
157
- ],
158
- [
159
- 139.76943969726562,
160
- 35.73425097869431,
161
- ],
162
- [
163
- 139.73922729492188,
164
- 35.66399091134812,
165
- ],
166
- [
167
- 139.70352172851562,
168
- 35.698571062054015,
169
- ],
185
+ [139.6870422363281, 35.73425097869431],
186
+ [139.76943969726562, 35.73425097869431],
187
+ [139.73922729492188, 35.66399091134812],
188
+ [139.70352172851562, 35.698571062054015],
170
189
  ];
171
190
 
172
191
  assert.deepEqual(expectCoordinates, coordinates);
@@ -184,7 +203,10 @@ describe('Tests for simpleStyle()', () => {
184
203
 
185
204
  await ss._loadingPromise;
186
205
 
187
- assert.deepEqual([ 'geolonia-simple-style', 'geolonia-simple-style-points' ], Object.keys(map.sources));
206
+ assert.deepEqual(
207
+ ['geolonia-simple-style', 'geolonia-simple-style-points'],
208
+ Object.keys(map.sources),
209
+ );
188
210
  assert.deepEqual(8, map.layers.length);
189
211
  assert.deepEqual(false, map.bounds);
190
212
  });
@@ -194,8 +216,8 @@ describe('Tests for simpleStyle()', () => {
194
216
 
195
217
  const map = new Map();
196
218
  const empty = {
197
- 'type': 'FeatureCollection',
198
- 'features': [],
219
+ type: 'FeatureCollection',
220
+ features: [],
199
221
  };
200
222
 
201
223
  const ss = new SimpleStyle(empty);
@@ -203,38 +225,27 @@ describe('Tests for simpleStyle()', () => {
203
225
 
204
226
  await ss._loadingPromise;
205
227
 
206
- const geojson = 'https://gist.githubusercontent.com/miya0001/56c3dc174f5cdf1d9565cbca0fbd3c48/raw/c13330036d28ef547a8a87cb6df3fa12de19ddb6/test.geojson';
228
+ const geojson =
229
+ 'https://gist.githubusercontent.com/miya0001/56c3dc174f5cdf1d9565cbca0fbd3c48/raw/c13330036d28ef547a8a87cb6df3fa12de19ddb6/test.geojson';
207
230
 
208
231
  ss.updateData(geojson);
209
232
 
210
233
  await ss._loadingPromise;
211
234
 
212
- const geometry = map.sources['geolonia-simple-style'].data.features[0].geometry;
235
+ const geometry =
236
+ map.sources['geolonia-simple-style'].data.features[0].geometry;
213
237
  const coordinates = geometry.coordinates;
214
238
  const type = geometry.type;
215
239
 
216
240
  const expectCoordinates = [
217
- [
218
- 139.6870422363281,
219
- 35.73425097869431,
220
- ],
221
- [
222
- 139.76943969726562,
223
- 35.73425097869431,
224
- ],
225
- [
226
- 139.73922729492188,
227
- 35.66399091134812,
228
- ],
229
- [
230
- 139.70352172851562,
231
- 35.698571062054015,
232
- ],
241
+ [139.6870422363281, 35.73425097869431],
242
+ [139.76943969726562, 35.73425097869431],
243
+ [139.73922729492188, 35.66399091134812],
244
+ [139.70352172851562, 35.698571062054015],
233
245
  ];
234
246
 
235
247
  assert.deepEqual(expectCoordinates, coordinates);
236
248
  assert.deepEqual('LineString', type);
237
249
  assert.deepEqual(true, map.bounds);
238
250
  });
239
-
240
251
  });
@@ -11,8 +11,8 @@ const backgroundColor = 'rgba(255, 0, 0, 0.4)';
11
11
  const strokeColor = '#FFFFFF';
12
12
 
13
13
  const template = {
14
- 'type': 'FeatureCollection',
15
- 'features': [],
14
+ type: 'FeatureCollection',
15
+ features: [],
16
16
  };
17
17
 
18
18
  export class SimpleStyle {
@@ -35,21 +35,24 @@ export class SimpleStyle {
35
35
  }
36
36
 
37
37
  updateData(geojson) {
38
-
39
38
  this.setGeoJSON(geojson);
40
39
 
41
40
  const features = this.geojson.features;
42
- const polygonandlines = features.filter((feature) => (feature.geometry.type.toLowerCase() !== 'point'));
43
- const points = features.filter((feature) => (feature.geometry.type.toLowerCase() === 'point'));
41
+ const polygonandlines = features.filter(
42
+ (feature) => feature.geometry.type.toLowerCase() !== 'point',
43
+ );
44
+ const points = features.filter(
45
+ (feature) => feature.geometry.type.toLowerCase() === 'point',
46
+ );
44
47
 
45
48
  this.map.getSource(this.options.id).setData({
46
- 'type': 'FeatureCollection',
47
- 'features': polygonandlines,
49
+ type: 'FeatureCollection',
50
+ features: polygonandlines,
48
51
  });
49
52
 
50
53
  this.map.getSource(`${this.options.id}-points`).setData({
51
- 'type': 'FeatureCollection',
52
- 'features': points,
54
+ type: 'FeatureCollection',
55
+ features: points,
53
56
  });
54
57
 
55
58
  return this;
@@ -59,8 +62,12 @@ export class SimpleStyle {
59
62
  this.map = map;
60
63
 
61
64
  const features = this.geojson.features;
62
- const polygonandlines = features.filter((feature) => (feature.geometry.type.toLowerCase() !== 'point'));
63
- const points = features.filter((feature) => (feature.geometry.type.toLowerCase() === 'point'));
65
+ const polygonandlines = features.filter(
66
+ (feature) => feature.geometry.type.toLowerCase() !== 'point',
67
+ );
68
+ const points = features.filter(
69
+ (feature) => feature.geometry.type.toLowerCase() === 'point',
70
+ );
64
71
 
65
72
  this.map.addSource(this.options.id, {
66
73
  type: 'geojson',
@@ -91,7 +98,11 @@ export class SimpleStyle {
91
98
  filter: ['==', '$type', 'Polygon'],
92
99
  paint: {
93
100
  'text-color': ['string', ['get', 'text-color'], textColor],
94
- 'text-halo-color': ['string', ['get', 'text-halo-color'], textHaloColor],
101
+ 'text-halo-color': [
102
+ 'string',
103
+ ['get', 'text-halo-color'],
104
+ textHaloColor,
105
+ ],
95
106
  'text-halo-width': 1,
96
107
  },
97
108
  layout: {
@@ -110,7 +121,11 @@ export class SimpleStyle {
110
121
  filter: ['==', '$type', 'LineString'],
111
122
  paint: {
112
123
  'text-color': ['string', ['get', 'text-color'], textColor],
113
- 'text-halo-color': ['string', ['get', 'text-halo-color'], textHaloColor],
124
+ 'text-halo-color': [
125
+ 'string',
126
+ ['get', 'text-halo-color'],
127
+ textHaloColor,
128
+ ],
114
129
  'text-halo-width': 1,
115
130
  },
116
131
  layout: {
@@ -130,7 +145,6 @@ export class SimpleStyle {
130
145
  }
131
146
 
132
147
  fitBounds(options = {}) {
133
-
134
148
  this.callFitBounds = true;
135
149
 
136
150
  const _options = {
@@ -203,8 +217,10 @@ export class SimpleStyle {
203
217
  paint: {
204
218
  'circle-radius': [
205
219
  'case',
206
- ['==', 'small', ['get', 'marker-size']], 7,
207
- ['==', 'large', ['get', 'marker-size']], 13,
220
+ ['==', 'small', ['get', 'marker-size']],
221
+ 7,
222
+ ['==', 'large', ['get', 'marker-size']],
223
+ 13,
208
224
  9,
209
225
  ],
210
226
  'circle-color': ['string', ['get', 'marker-color'], backgroundColor],
@@ -222,7 +238,11 @@ export class SimpleStyle {
222
238
  filter: ['!', ['has', 'point_count']],
223
239
  paint: {
224
240
  'text-color': ['string', ['get', 'text-color'], textColor],
225
- 'text-halo-color': ['string', ['get', 'text-halo-color'], textHaloColor],
241
+ 'text-halo-color': [
242
+ 'string',
243
+ ['get', 'text-halo-color'],
244
+ textHaloColor,
245
+ ],
226
246
  'text-halo-width': 1,
227
247
  },
228
248
  layout: {
@@ -236,8 +256,10 @@ export class SimpleStyle {
236
256
  'text-variable-anchor': ['top', 'bottom', 'left', 'right'],
237
257
  'text-radial-offset': [
238
258
  'case',
239
- ['==', 'small', ['get', 'marker-size']], 1,
240
- ['==', 'large', ['get', 'marker-size']], 1.6,
259
+ ['==', 'small', ['get', 'marker-size']],
260
+ 1,
261
+ ['==', 'large', ['get', 'marker-size']],
262
+ 1.6,
241
263
  1.2,
242
264
  ],
243
265
  },
@@ -249,12 +271,18 @@ export class SimpleStyle {
249
271
 
250
272
  async setPopup(map, source) {
251
273
  map.on('click', source, async (e) => {
252
- const center = turfCenter(e.features[0]).geometry.coordinates as [ number, number ];
274
+ const center = turfCenter(e.features[0]).geometry.coordinates as [
275
+ number,
276
+ number,
277
+ ];
253
278
  const description = e.features[0].properties.description;
254
279
 
255
280
  if (description) {
256
281
  const sanitizedDescription = await sanitizeDescription(description);
257
- new maplibregl.Popup().setLngLat(center).setHTML(sanitizedDescription).addTo(map);
282
+ new maplibregl.Popup()
283
+ .setLngLat(center)
284
+ .setHTML(sanitizedDescription)
285
+ .addTo(map);
258
286
  }
259
287
  });
260
288
 
@@ -298,9 +326,13 @@ export class SimpleStyle {
298
326
  });
299
327
 
300
328
  this.map.on('click', `${this.options.id}-clusters`, async (e) => {
301
- const features = this.map.queryRenderedFeatures(e.point, { layers: [`${this.options.id}-clusters`] });
329
+ const features = this.map.queryRenderedFeatures(e.point, {
330
+ layers: [`${this.options.id}-clusters`],
331
+ });
302
332
  const clusterId = features[0].properties.cluster_id;
303
- const zoom = await this.map.getSource(`${this.options.id}-points`).getClusterExpansionZoom(clusterId);
333
+ const zoom = await this.map
334
+ .getSource(`${this.options.id}-points`)
335
+ .getClusterExpansionZoom(clusterId);
304
336
 
305
337
  this.map.easeTo({
306
338
  center: features[0].geometry.coordinates,
@@ -318,39 +350,28 @@ export class SimpleStyle {
318
350
  }
319
351
 
320
352
  setGeoJSON(geojson) {
321
-
322
353
  if (typeof geojson === 'string' && isURL(geojson)) {
323
-
324
354
  this.geojson = template;
325
355
 
326
356
  const fetchGeoJSON = async () => {
327
-
328
357
  try {
329
-
330
358
  const response = await window.fetch(geojson);
331
359
  const data = response.ok ? await response.json() : {};
332
360
  this.geojson = data;
333
361
  this.updateData(data);
334
362
 
335
363
  if (this.callFitBounds) {
336
-
337
364
  this.fitBounds();
338
365
  this.callFitBounds = false;
339
-
340
366
  }
341
-
342
367
  } catch (error) {
343
-
344
368
  console.error('[Geolonia] Failed to load GeoJSON:', error); // eslint-disable-line no-console
345
369
  }
346
-
347
370
  };
348
371
 
349
372
  this._loadingPromise = fetchGeoJSON();
350
-
351
373
  } else {
352
374
  this.geojson = geojson;
353
375
  }
354
-
355
376
  }
356
377
  }