@geolonia/embed 2.0.0-pre.4 → 2.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geolonia/embed",
3
- "version": "2.0.0-pre.4",
3
+ "version": "2.0.1",
4
4
  "description": "Geolonia embed JS API",
5
5
  "main": "dist/embed.js",
6
6
  "types": "src/embed.d.ts",
package/src/embed.js CHANGED
@@ -13,6 +13,7 @@ import * as util from './lib/util';
13
13
  import parseAtts from './lib/parse-atts';
14
14
  import parseApiKey from './lib/parse-api-key';
15
15
  import pkg from '../package.json';
16
+ import simpleStyle from './lib/simplestyle';
16
17
 
17
18
  if ( util.checkPermission() ) {
18
19
  let isDOMContentLoaded = false;
@@ -77,6 +78,7 @@ if ( util.checkPermission() ) {
77
78
  }
78
79
 
79
80
  window.geolonia.Map = GeoloniaMap;
81
+ window.geolonia.simpleStyle = simpleStyle;
80
82
  window.geolonia.Marker = GeoloniaMarker;
81
83
  window.geolonia.AmazonLocationServiceMapProvider = AmazonLocationServiceMapProvider;
82
84
  window.geolonia.embedVersion = pkg.version;
@@ -11,23 +11,48 @@ const backgroundColor = 'rgba(255, 0, 0, 0.4)';
11
11
  const strokeColor = '#FFFFFF';
12
12
 
13
13
  class SimpleStyle {
14
- constructor(json, options) {
15
- this.json = json;
14
+ constructor(geojson, options) {
15
+ this.geojson = geojson;
16
16
 
17
17
  this.options = {
18
+ id: 'geolonia-simple-style',
18
19
  cluster: true,
19
- heatmap: false,
20
+ heatmap: false, // TODO: It should support heatmap.
20
21
  clusterColor: '#ff0000',
22
+ duration: 3000,
23
+ padding: 30,
21
24
  ...options,
22
25
  };
23
26
  }
24
27
 
28
+ updateData(geojson) {
29
+ const features = geojson.features;
30
+ const polygonandlines = features.filter((feature) => (feature.geometry.type.toLowerCase() !== 'point'));
31
+ const points = features.filter((feature) => (feature.geometry.type.toLowerCase() === 'point'));
32
+
33
+ this.map.getSource(this.options.id).setData({
34
+ 'type': 'FeatureCollection',
35
+ 'features': polygonandlines,
36
+ });
37
+
38
+ this.map.getSource(`${this.options.id}-points`).setData({
39
+ 'type': 'FeatureCollection',
40
+ 'features': points,
41
+ });
42
+
43
+ this.geojson = geojson;
44
+
45
+ return this;
46
+ }
47
+
25
48
  addTo(map) {
26
- const features = this.json.features;
49
+ this.map = map;
50
+
51
+ const features = this.geojson.features;
27
52
  const polygonandlines = features.filter((feature) => (feature.geometry.type.toLowerCase() !== 'point'));
28
53
  const points = features.filter((feature) => (feature.geometry.type.toLowerCase() === 'point'));
29
54
 
30
- map.addSource('geolonia-simple-style', {
55
+ this.map.addSource(this.options.id, {
31
56
  type: 'geojson',
32
57
  data: {
33
58
  type: 'FeatureCollection',
@@ -35,10 +60,10 @@ class SimpleStyle {
35
60
  },
36
61
  });
37
62
 
38
- this.setPolygonGeometries(map);
39
- this.setLineGeometries(map);
63
+ this.setPolygonGeometries();
64
+ this.setLineGeometries();
40
65
 
41
- map.addSource('geolonia-simple-style-points', {
66
+ this.map.addSource(`${this.options.id}-points`, {
42
67
  type: 'geojson',
43
68
  data: {
44
69
  type: 'FeatureCollection',
@@ -49,10 +74,10 @@ class SimpleStyle {
49
74
  clusterRadius: 50,
50
75
  });
51
76
 
52
- map.addLayer({
53
- id: 'geolonia-simple-style-polygon-symbol',
77
+ this.map.addLayer({
78
+ id: `${this.options.id}-polygon-symbol`,
54
79
  type: 'symbol',
55
- source: 'geolonia-simple-style',
80
+ source: this.options.id,
56
81
  filter: ['==', '$type', 'Polygon'],
57
82
  paint: {
58
83
  'text-color': ['string', ['get', 'text-color'], textColor],
@@ -68,10 +93,10 @@ class SimpleStyle {
68
93
  },
69
94
  });
70
95
 
71
- map.addLayer({
72
- id: 'geolonia-simple-style-linestring-symbol',
96
+ this.map.addLayer({
97
+ id: `${this.options.id}-linestring-symbol`,
73
98
  type: 'symbol',
74
- source: 'geolonia-simple-style',
99
+ source: this.options.id,
75
100
  filter: ['==', '$type', 'LineString'],
76
101
  paint: {
77
102
  'text-color': ['string', ['get', 'text-color'], textColor],
@@ -88,30 +113,32 @@ class SimpleStyle {
88
113
  },
89
114
  });
90
115
 
91
- this.setPointGeometries(map);
92
- this.setCluster(map);
116
+ this.setPointGeometries();
117
+ this.setCluster();
93
118
 
94
- const container = map.getContainer();
119
+ const container = this.map.getContainer();
95
120
 
96
121
  if (!container.dataset || (!container.dataset.lng && !container.dataset.lat)) {
97
- const bounds = geojsonExtent(this.json);
98
- map.fitBounds(bounds, {
99
- duration: 0,
100
- padding: 30,
101
- });
122
+ const bounds = geojsonExtent(this.geojson);
123
+ if (bounds) {
124
+ this.map.fitBounds(bounds, {
125
+ duration: this.options.duration,
126
+ padding: this.options.padding,
127
+ });
128
+ }
102
129
  }
130
+
131
+ return this;
103
132
  }
104
133
 
105
134
  /**
106
135
  * Set polygon geometries.
107
- *
108
- * @param map
109
136
  */
110
- setPolygonGeometries(map) {
111
- map.addLayer({
112
- id: 'geolonia-simple-style-polygon',
137
+ setPolygonGeometries() {
138
+ this.map.addLayer({
139
+ id: `${this.options.id}-polygon`,
113
140
  type: 'fill',
114
- source: 'geolonia-simple-style',
141
+ source: this.options.id,
115
142
  filter: ['==', '$type', 'Polygon'],
116
143
  paint: {
117
144
  'fill-color': ['string', ['get', 'fill'], backgroundColor],
@@ -120,19 +147,17 @@ class SimpleStyle {
120
147
  },
121
148
  });
122
149
 
123
- this.setPopup(map, 'geolonia-simple-style-polygon');
150
+ this.setPopup(this.map, `${this.options.id}-polygon`);
124
151
  }
125
152
 
126
153
  /**
127
154
  * Set line geometries.
128
- *
129
- * @param map
130
155
  */
131
- setLineGeometries(map) {
132
- map.addLayer({
133
- id: 'geolonia-simple-style-linestring',
156
+ setLineGeometries() {
157
+ this.map.addLayer({
158
+ id: `${this.options.id}-linestring`,
134
159
  type: 'line',
135
- source: 'geolonia-simple-style',
160
+ source: this.options.id,
136
161
  filter: ['==', '$type', 'LineString'],
137
162
  paint: {
138
163
  'line-width': ['number', ['get', 'stroke-width'], 2],
@@ -145,19 +170,17 @@ class SimpleStyle {
145
170
  },
146
171
  });
147
172
 
148
- this.setPopup(map, 'geolonia-simple-style-linestring');
173
+ this.setPopup(this.map, `${this.options.id}-linestring`);
149
174
  }
150
175
 
151
176
  /**
152
177
  * Setup point geometries.
153
- *
154
- * @param map
155
178
  */
156
- setPointGeometries(map) {
157
- map.addLayer({
158
- id: 'circle-simple-style-points',
179
+ setPointGeometries() {
180
+ this.map.addLayer({
181
+ id: `${this.options.id}-circle-points`,
159
182
  type: 'circle',
160
- source: 'geolonia-simple-style-points',
183
+ source: `${this.options.id}-points`,
161
184
  filter: ['!', ['has', 'point_count']],
162
185
  paint: {
163
186
  'circle-radius': [
@@ -174,10 +197,10 @@ class SimpleStyle {
174
197
  },
175
198
  });
176
199
 
177
- map.addLayer({
178
- id: 'symbol-simple-style-points',
200
+ this.map.addLayer({
201
+ id: `${this.options.id}-symbol-points`,
179
202
  type: 'symbol',
180
- source: 'geolonia-simple-style-points',
203
+ source: `${this.options.id}-points`,
181
204
  filter: ['!', ['has', 'point_count']],
182
205
  paint: {
183
206
  'text-color': ['string', ['get', 'text-color'], textColor],
@@ -205,7 +228,7 @@ class SimpleStyle {
205
228
  },
206
229
  });
207
230
 
208
- this.setPopup(map, 'circle-simple-style-points');
231
+ this.setPopup(this.map, `${this.options.id}-circle-points`);
209
232
  }
210
233
 
211
234
  setPopup(map, source) {
@@ -231,14 +254,12 @@ class SimpleStyle {
231
254
 
232
255
  /**
233
256
  * Setup cluster markers
234
- *
235
- * @param map
236
257
  */
237
- setCluster(map) {
238
- map.addLayer({
239
- id: 'clusters',
258
+ setCluster() {
259
+ this.map.addLayer({
260
+ id: `${this.options.id}-clusters`,
240
261
  type: 'circle',
241
- source: 'geolonia-simple-style-points',
262
+ source: `${this.options.id}-points`,
242
263
  filter: ['has', 'point_count'],
243
264
  paint: {
244
265
  'circle-radius': 20,
@@ -247,10 +268,10 @@ class SimpleStyle {
247
268
  },
248
269
  });
249
270
 
250
- map.addLayer({
251
- id: 'cluster-count',
271
+ this.map.addLayer({
272
+ id: `${this.options.id}-cluster-count`,
252
273
  type: 'symbol',
253
- source: 'geolonia-simple-style-points',
274
+ source: `${this.options.id}-points`,
254
275
  filter: ['has', 'point_count'],
255
276
  layout: {
256
277
  'text-field': '{point_count_abbreviated}',
@@ -259,26 +280,26 @@ class SimpleStyle {
259
280
  },
260
281
  });
261
282
 
262
- map.on('click', 'clusters', (e) => {
263
- const features = map.queryRenderedFeatures(e.point, { layers: ['clusters'] });
283
+ this.map.on('click', `${this.options.id}-clusters`, (e) => {
284
+ const features = this.map.queryRenderedFeatures(e.point, { layers: [`${this.options.id}-clusters`] });
264
285
  const clusterId = features[0].properties.cluster_id;
265
- map.getSource('geolonia-simple-style-points').getClusterExpansionZoom(clusterId, (err, zoom) => {
286
+ this.map.getSource(`${this.options.id}-points`).getClusterExpansionZoom(clusterId, (err, zoom) => {
266
287
  if (err)
267
288
  return;
268
289
 
269
- map.easeTo({
290
+ this.map.easeTo({
270
291
  center: features[0].geometry.coordinates,
271
292
  zoom: zoom,
272
293
  });
273
294
  });
274
295
  });
275
296
 
276
- map.on('mouseenter', 'clusters', () => {
277
- map.getCanvas().style.cursor = 'pointer';
297
+ this.map.on('mouseenter', `${this.options.id}-clusters`, () => {
298
+ this.map.getCanvas().style.cursor = 'pointer';
278
299
  });
279
300
 
280
- map.on('mouseleave', 'clusters', () => {
281
- map.getCanvas().style.cursor = '';
301
+ this.map.on('mouseleave', `${this.options.id}-clusters`, () => {
302
+ this.map.getCanvas().style.cursor = '';
282
303
  });
283
304
  }
284
305
  }
@@ -0,0 +1,135 @@
1
+ 'use strict';
2
+
3
+ import assert from 'assert';
4
+
5
+ class Map {
6
+ constructor(json, options) {
7
+ this.json = json;
8
+ this.options = options;
9
+ this.sources = {};
10
+ this.layers = [];
11
+ this.bounds = false;
12
+ }
13
+
14
+ addSource(id, source) {
15
+ this.sources[id] = source;
16
+ }
17
+
18
+ addLayer(layer) {
19
+ this.layers.push(layer);
20
+ }
21
+
22
+ on() {
23
+
24
+ }
25
+
26
+ getSource(id) {
27
+ class getSource {
28
+ constructor(id, sources) {
29
+ this.id = id;
30
+ this.sources = sources;
31
+ }
32
+ setData(geojson) {
33
+ this.sources[this.id] = {
34
+ type: 'geojson',
35
+ data: geojson,
36
+ };
37
+ }
38
+ }
39
+
40
+ return new getSource(id, this.sources);
41
+ }
42
+
43
+ getContainer() {
44
+ return { dataset: true };
45
+ }
46
+
47
+ // It should not be fired if GeoJSON is empty.
48
+ fitBounds() {
49
+ this.bounds = true;
50
+ }
51
+ }
52
+
53
+ const geojson = {
54
+ 'type': 'FeatureCollection',
55
+ 'features': [
56
+ {
57
+ 'type': 'Feature',
58
+ 'properties': {},
59
+ 'geometry': {
60
+ 'type': 'Point',
61
+ 'coordinates': [
62
+ 139.77012634277344,
63
+ 35.68518697509636,
64
+ ],
65
+ },
66
+ },
67
+ ],
68
+ };
69
+
70
+ describe('Tests for simpleStyle()', () => {
71
+ it('should has sources and layers as expected', async () => {
72
+ window.URL.createObjectURL = () => {}; // To prevent `TypeError: window.URL.createObjectURL is not a function`
73
+ const { default: simpleStyle } = await import('./simplestyle');
74
+
75
+ const map = new Map();
76
+ new simpleStyle(geojson).addTo(map);
77
+
78
+ assert.deepEqual([ 'geolonia-simple-style', 'geolonia-simple-style-points' ], Object.keys(map.sources));
79
+ assert.deepEqual(8, map.layers.length);
80
+ assert.deepEqual(true, map.bounds);
81
+ });
82
+
83
+ it('should has sources and layers as expected with custom IDs', async () => {
84
+ window.URL.createObjectURL = () => {}; // To prevent `TypeError: window.URL.createObjectURL is not a function`
85
+ const { default: simpleStyle } = await import('./simplestyle');
86
+
87
+ const map = new Map();
88
+ new simpleStyle(geojson, {id: 'hello-world'}).addTo(map);
89
+
90
+ assert.deepEqual([ 'hello-world', 'hello-world-points' ], Object.keys(map.sources));
91
+ assert.deepEqual(8, map.layers.length);
92
+ assert.deepEqual(true, map.bounds);
93
+ });
94
+
95
+ it('should has sources and layers as expected with empty GeoJSON', async () => {
96
+ window.URL.createObjectURL = () => {}; // To prevent `TypeError: window.URL.createObjectURL is not a function`
97
+ const { default: simpleStyle } = await import('./simplestyle');
98
+
99
+ const map = new Map();
100
+
101
+ const empty = {
102
+ 'type': 'FeatureCollection',
103
+ 'features': [],
104
+ };
105
+
106
+ new simpleStyle(empty, {id: 'hello-world'}).addTo(map);
107
+
108
+ assert.deepEqual([ 'hello-world', 'hello-world-points' ], Object.keys(map.sources));
109
+ assert.deepEqual(8, map.layers.length);
110
+ assert.deepEqual(false, map.bounds);
111
+ });
112
+
113
+ it('should update GeoJSON', async () => {
114
+ window.URL.createObjectURL = () => {}; // To prevent `TypeError: window.URL.createObjectURL is not a function`
115
+ const { default: simpleStyle } = await import('./simplestyle');
116
+
117
+ const map = new Map();
118
+
119
+ const empty = {
120
+ 'type': 'FeatureCollection',
121
+ 'features': [],
122
+ };
123
+
124
+ const ss = new simpleStyle(empty).addTo(map); // The GeoJSON is empty.
125
+
126
+ assert.deepEqual([ 'geolonia-simple-style', 'geolonia-simple-style-points' ], Object.keys(map.sources));
127
+ assert.deepEqual(8, map.layers.length);
128
+ assert.deepEqual(false, map.bounds);
129
+ assert.deepEqual(0, map.sources['geolonia-simple-style-points'].data.features.length);
130
+
131
+ ss.updateData(geojson); // The GeoJSON is not empty.
132
+ assert.deepEqual(false, map.bounds); // `fitBounds()` doesn't fire.
133
+ assert.deepEqual(1, map.sources['geolonia-simple-style-points'].data.features.length);
134
+ });
135
+ });
@@ -27,6 +27,7 @@ describe('Tests for Maps.', () => {
27
27
 
28
28
  // prepare pupeteer
29
29
  browser = await puppeteer.launch({
30
+ headless: true,
30
31
  args:
31
32
  process.env.NO_SANDBOX === 'true'
32
33
  ? ['--no-sandbox', '--disable-setuid-sandbox'] // for Docker env
@@ -41,7 +42,7 @@ describe('Tests for Maps.', () => {
41
42
  const content = template
42
43
  .replace(/%ORIGIN%/g, 'http://127.0.0.1:8080')
43
44
  .replace(/%API_KEY%/g, process.env.GEOLONIA_API_KEY || 'YOUR-API-KEY')
44
- await page.goto('https://geolonia.com')
45
+ await page.goto('https://geoloniamaps.github.io/basic/')
45
46
  page.on('pageerror', error => capturedErrors.push(error))
46
47
  await page.setContent(content)
47
48
  await sleep(15000)
@@ -1 +0,0 @@
1
- (self.webpackChunk_geolonia_embed=self.webpackChunk_geolonia_embed||[]).push([[337],{6613:e=>{function t(e){if(!(this instanceof t))return new t(e);this._bbox=e||[1/0,1/0,-1/0,-1/0],this._valid=!!e}e.exports=t,t.prototype.include=function(e){return this._valid=!0,this._bbox[0]=Math.min(this._bbox[0],e[0]),this._bbox[1]=Math.min(this._bbox[1],e[1]),this._bbox[2]=Math.max(this._bbox[2],e[0]),this._bbox[3]=Math.max(this._bbox[3],e[1]),this},t.prototype.equals=function(e){var o;return o=e instanceof t?e.bbox():e,this._bbox[0]==o[0]&&this._bbox[1]==o[1]&&this._bbox[2]==o[2]&&this._bbox[3]==o[3]},t.prototype.center=function(e){return this._valid?[(this._bbox[0]+this._bbox[2])/2,(this._bbox[1]+this._bbox[3])/2]:null},t.prototype.union=function(e){var o;return this._valid=!0,o=e instanceof t?e.bbox():e,this._bbox[0]=Math.min(this._bbox[0],o[0]),this._bbox[1]=Math.min(this._bbox[1],o[1]),this._bbox[2]=Math.max(this._bbox[2],o[2]),this._bbox[3]=Math.max(this._bbox[3],o[3]),this},t.prototype.bbox=function(){return this._valid?this._bbox:null},t.prototype.contains=function(e){if(!e)return this._fastContains();if(!this._valid)return null;var t=e[0],o=e[1];return this._bbox[0]<=t&&this._bbox[1]<=o&&this._bbox[2]>=t&&this._bbox[3]>=o},t.prototype.intersect=function(e){return this._valid?(o=e instanceof t?e.bbox():e,!(this._bbox[0]>o[2]||this._bbox[2]<o[0]||this._bbox[3]<o[1]||this._bbox[1]>o[3])):null;var o},t.prototype._fastContains=function(){if(!this._valid)return new Function("return null;");var e="return "+this._bbox[0]+"<= ll[0] &&"+this._bbox[1]+"<= ll[1] &&"+this._bbox[2]+">= ll[0] &&"+this._bbox[3]+">= ll[1]";return new Function("ll",e)},t.prototype.polygon=function(){return this._valid?{type:"Polygon",coordinates:[[[this._bbox[0],this._bbox[1]],[this._bbox[2],this._bbox[1]],[this._bbox[2],this._bbox[3]],[this._bbox[0],this._bbox[3]],[this._bbox[0],this._bbox[1]]]]}:null}},7829:e=>{e.exports=function(e){return function e(t){return Array.isArray(t)&&t.length&&"number"==typeof t[0]?[t]:t.reduce((function(t,o){return Array.isArray(o)&&Array.isArray(o[0])?t.concat(e(o)):(t.push(o),t)}),[])}(e)}},4506:(e,t,o)=>{var r=o(9340),n=o(11),i=o(7829);e.exports=function(e){if(!e)return[];var t=n(r(e)),o=[];return t.features.forEach((function(e){e.geometry&&(o=o.concat(i(e.geometry.coordinates)))})),o}},9319:(e,t,o)=>{var r=o(4506),n=o(3692),i=o(6613),s={features:["FeatureCollection"],coordinates:["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],geometry:["Feature"],geometries:["GeometryCollection"]},l=Object.keys(s);function a(e){for(var t=i(),o=r(e),n=0;n<o.length;n++)t.include(o[n]);return t}e.exports=function(e){return a(e).bbox()},e.exports.polygon=function(e){return a(e).polygon()},e.exports.bboxify=function(e){return n(e).map((function(e){e&&l.some((function(t){return!!e[t]&&-1!==s[t].indexOf(e.type)}))&&(e.bbox=a(e).bbox(),this.update(e))}))}},9340:e=>{e.exports=function(e){if(!e||!e.type)return null;var o=t[e.type];return o?"geometry"===o?{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:e}]}:"feature"===o?{type:"FeatureCollection",features:[e]}:"featurecollection"===o?e:void 0:null};var t={Point:"geometry",MultiPoint:"geometry",LineString:"geometry",MultiLineString:"geometry",Polygon:"geometry",MultiPolygon:"geometry",GeometryCollection:"geometry",Feature:"feature",FeatureCollection:"featurecollection"}},8714:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>d}),o(7327),o(2526),o(1817),o(9070),o(7941),o(5003),o(9554),o(4747),o(9337),o(3321);var r=o(2739),n=o.n(r),i=o(9319),s=o.n(i),l=o(1235),a=o(8007),u=o.n(a);function c(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,r)}return o}function p(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function f(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var y="#000000",b="#FFFFFF",h="rgba(255, 0, 0, 0.4)",g="#FFFFFF";const d=function(){function e(t,o){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.json=t,this.options=function(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?c(Object(o),!0).forEach((function(t){p(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):c(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}({cluster:!0,heatmap:!1,clusterColor:"#ff0000"},o)}var t,o;return t=e,(o=[{key:"addTo",value:function(e){var t=this.json.features,o=t.filter((function(e){return"point"!==e.geometry.type.toLowerCase()})),r=t.filter((function(e){return"point"===e.geometry.type.toLowerCase()}));e.addSource("geolonia-simple-style",{type:"geojson",data:{type:"FeatureCollection",features:o}}),this.setPolygonGeometries(e),this.setLineGeometries(e),e.addSource("geolonia-simple-style-points",{type:"geojson",data:{type:"FeatureCollection",features:r},cluster:this.options.cluster,clusterMaxZoom:14,clusterRadius:50}),e.addLayer({id:"geolonia-simple-style-polygon-symbol",type:"symbol",source:"geolonia-simple-style",filter:["==","$type","Polygon"],paint:{"text-color":["string",["get","text-color"],y],"text-halo-color":["string",["get","text-halo-color"],b],"text-halo-width":1},layout:{"text-field":["get","title"],"text-font":["Noto Sans Regular"],"text-size":12,"text-max-width":12,"text-allow-overlap":!1}}),e.addLayer({id:"geolonia-simple-style-linestring-symbol",type:"symbol",source:"geolonia-simple-style",filter:["==","$type","LineString"],paint:{"text-color":["string",["get","text-color"],y],"text-halo-color":["string",["get","text-halo-color"],b],"text-halo-width":1},layout:{"symbol-placement":"line","text-field":["get","title"],"text-font":["Noto Sans Regular"],"text-size":12,"text-max-width":12,"text-allow-overlap":!1}}),this.setPointGeometries(e),this.setCluster(e);var n=e.getContainer();if(!n.dataset||!n.dataset.lng&&!n.dataset.lat){var i=s()(this.json);e.fitBounds(i,{duration:0,padding:30})}}},{key:"setPolygonGeometries",value:function(e){e.addLayer({id:"geolonia-simple-style-polygon",type:"fill",source:"geolonia-simple-style",filter:["==","$type","Polygon"],paint:{"fill-color":["string",["get","fill"],h],"fill-opacity":["number",["get","fill-opacity"],1],"fill-outline-color":["string",["get","stroke"],g]}}),this.setPopup(e,"geolonia-simple-style-polygon")}},{key:"setLineGeometries",value:function(e){e.addLayer({id:"geolonia-simple-style-linestring",type:"line",source:"geolonia-simple-style",filter:["==","$type","LineString"],paint:{"line-width":["number",["get","stroke-width"],2],"line-color":["string",["get","stroke"],h],"line-opacity":["number",["get","stroke-opacity"],1]},layout:{"line-cap":"round","line-join":"round"}}),this.setPopup(e,"geolonia-simple-style-linestring")}},{key:"setPointGeometries",value:function(e){e.addLayer({id:"circle-simple-style-points",type:"circle",source:"geolonia-simple-style-points",filter:["!",["has","point_count"]],paint:{"circle-radius":["case",["==","small",["get","marker-size"]],7,["==","large",["get","marker-size"]],13,9],"circle-color":["string",["get","marker-color"],h],"circle-opacity":["number",["get","fill-opacity"],1],"circle-stroke-width":["number",["get","stroke-width"],1],"circle-stroke-color":["string",["get","stroke"],g],"circle-stroke-opacity":["number",["get","stroke-opacity"],1]}}),e.addLayer({id:"symbol-simple-style-points",type:"symbol",source:"geolonia-simple-style-points",filter:["!",["has","point_count"]],paint:{"text-color":["string",["get","text-color"],y],"text-halo-color":["string",["get","text-halo-color"],b],"text-halo-width":1},layout:{"icon-image":["case",["==","large",["get","marker-size"]],["image",["concat",["get","marker-symbol"],"-15"]],["image",["concat",["get","marker-symbol"],"-11"]]],"text-field":["get","title"],"text-font":["Noto Sans Regular"],"text-size":12,"text-anchor":"top","text-max-width":12,"text-offset":["case",["==","small",["get","marker-size"]],["literal",[0,.6]],["==","large",["get","marker-size"]],["literal",[0,1.2]],["literal",[0,.8]]],"text-allow-overlap":!1}}),this.setPopup(e,"circle-simple-style-points")}},{key:"setPopup",value:function(e,t){e.on("click",t,(function(t){var o=(0,l.Z)(t.features[0]).geometry.coordinates,r=t.features[0].properties.description;r&&(new(n().Popup)).setLngLat(o).setHTML(u()(r)).addTo(e)})),e.on("mouseenter",t,(function(t){t.features[0].properties.description&&(e.getCanvas().style.cursor="pointer")})),e.on("mouseleave",t,(function(){e.getCanvas().style.cursor=""}))}},{key:"setCluster",value:function(e){e.addLayer({id:"clusters",type:"circle",source:"geolonia-simple-style-points",filter:["has","point_count"],paint:{"circle-radius":20,"circle-color":this.options.clusterColor,"circle-opacity":1}}),e.addLayer({id:"cluster-count",type:"symbol",source:"geolonia-simple-style-points",filter:["has","point_count"],layout:{"text-field":"{point_count_abbreviated}","text-size":14,"text-font":["Noto Sans Regular"]}}),e.on("click","clusters",(function(t){var o=e.queryRenderedFeatures(t.point,{layers:["clusters"]}),r=o[0].properties.cluster_id;e.getSource("geolonia-simple-style-points").getClusterExpansionZoom(r,(function(t,r){t||e.easeTo({center:o[0].geometry.coordinates,zoom:r})}))})),e.on("mouseenter","clusters",(function(){e.getCanvas().style.cursor="pointer"})),e.on("mouseleave","clusters",(function(){e.getCanvas().style.cursor=""}))}}])&&f(t.prototype,o),e}()},11:e=>{e.exports=function e(t){switch(t&&t.type||null){case"FeatureCollection":return t.features=t.features.reduce((function(t,o){return t.concat(e(o))}),[]),t;case"Feature":return t.geometry?e(t.geometry).map((function(e){var o={type:"Feature",properties:JSON.parse(JSON.stringify(t.properties)),geometry:e};return void 0!==t.id&&(o.id=t.id),o})):t;case"MultiPoint":return t.coordinates.map((function(e){return{type:"Point",coordinates:e}}));case"MultiPolygon":return t.coordinates.map((function(e){return{type:"Polygon",coordinates:e}}));case"MultiLineString":return t.coordinates.map((function(e){return{type:"LineString",coordinates:e}}));case"GeometryCollection":return t.geometries.map(e).reduce((function(e,t){return e.concat(t)}),[]);case"Point":case"Polygon":case"LineString":return[t]}}},3692:e=>{var t=e.exports=function(e){return new o(e)};function o(e){this.value=e}function r(e,t,o){var r=[],s=[],c=!0;return function e(p){var f=o?n(p):p,y={},b=!0,h={node:f,node_:p,path:[].concat(r),parent:s[s.length-1],parents:s,key:r.slice(-1)[0],isRoot:0===r.length,level:r.length,circular:null,update:function(e,t){h.isRoot||(h.parent.node[h.key]=e),h.node=e,t&&(b=!1)},delete:function(e){delete h.parent.node[h.key],e&&(b=!1)},remove:function(e){l(h.parent.node)?h.parent.node.splice(h.key,1):delete h.parent.node[h.key],e&&(b=!1)},keys:null,before:function(e){y.before=e},after:function(e){y.after=e},pre:function(e){y.pre=e},post:function(e){y.post=e},stop:function(){c=!1},block:function(){b=!1}};if(!c)return h;function g(){if("object"==typeof h.node&&null!==h.node){h.keys&&h.node_===h.node||(h.keys=i(h.node)),h.isLeaf=0==h.keys.length;for(var e=0;e<s.length;e++)if(s[e].node_===p){h.circular=s[e];break}}else h.isLeaf=!0,h.keys=null;h.notLeaf=!h.isLeaf,h.notRoot=!h.isRoot}g();var d=t.call(h,h.node);return void 0!==d&&h.update&&h.update(d),y.before&&y.before.call(h,h.node),b?("object"!=typeof h.node||null===h.node||h.circular||(s.push(h),g(),a(h.keys,(function(t,n){r.push(t),y.pre&&y.pre.call(h,h.node[t],t);var i=e(h.node[t]);o&&u.call(h.node,t)&&(h.node[t]=i.node),i.isLast=n==h.keys.length-1,i.isFirst=0==n,y.post&&y.post.call(h,i),r.pop()})),s.pop()),y.after&&y.after.call(h,h.node),h):h}(e).node}function n(e){if("object"==typeof e&&null!==e){var t;if(l(e))t=[];else if("[object Date]"===s(e))t=new Date(e.getTime?e.getTime():e);else if("[object RegExp]"===s(e))t=new RegExp(e);else if(function(e){return"[object Error]"===s(e)}(e))t={message:e.message};else if(function(e){return"[object Boolean]"===s(e)}(e))t=new Boolean(e);else if(function(e){return"[object Number]"===s(e)}(e))t=new Number(e);else if(function(e){return"[object String]"===s(e)}(e))t=new String(e);else if(Object.create&&Object.getPrototypeOf)t=Object.create(Object.getPrototypeOf(e));else if(e.constructor===Object)t={};else{var o=e.constructor&&e.constructor.prototype||e.__proto__||{},r=function(){};r.prototype=o,t=new r}return a(i(e),(function(o){t[o]=e[o]})),t}return e}o.prototype.get=function(e){for(var t=this.value,o=0;o<e.length;o++){var r=e[o];if(!t||!u.call(t,r)){t=void 0;break}t=t[r]}return t},o.prototype.has=function(e){for(var t=this.value,o=0;o<e.length;o++){var r=e[o];if(!t||!u.call(t,r))return!1;t=t[r]}return!0},o.prototype.set=function(e,t){for(var o=this.value,r=0;r<e.length-1;r++){var n=e[r];u.call(o,n)||(o[n]={}),o=o[n]}return o[e[r]]=t,t},o.prototype.map=function(e){return r(this.value,e,!0)},o.prototype.forEach=function(e){return this.value=r(this.value,e,!1),this.value},o.prototype.reduce=function(e,t){var o=1===arguments.length,r=o?this.value:t;return this.forEach((function(t){this.isRoot&&o||(r=e.call(this,r,t))})),r},o.prototype.paths=function(){var e=[];return this.forEach((function(t){e.push(this.path)})),e},o.prototype.nodes=function(){var e=[];return this.forEach((function(t){e.push(this.node)})),e},o.prototype.clone=function(){var e=[],t=[];return function o(r){for(var s=0;s<e.length;s++)if(e[s]===r)return t[s];if("object"==typeof r&&null!==r){var l=n(r);return e.push(r),t.push(l),a(i(r),(function(e){l[e]=o(r[e])})),e.pop(),t.pop(),l}return r}(this.value)};var i=Object.keys||function(e){var t=[];for(var o in e)t.push(o);return t};function s(e){return Object.prototype.toString.call(e)}var l=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},a=function(e,t){if(e.forEach)return e.forEach(t);for(var o=0;o<e.length;o++)t(e[o],o,e)};a(i(o.prototype),(function(e){t[e]=function(t){var r=[].slice.call(arguments,1),n=new o(t);return n[e].apply(n,r)}}));var u=Object.hasOwnProperty||function(e,t){return t in e}},2868:()=>{},4777:()=>{},9830:()=>{},209:()=>{},7414:()=>{}}]);