@kizmann/pico-js 0.3.14 → 0.3.17

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": "@kizmann/pico-js",
3
- "version": "0.3.14",
3
+ "version": "0.3.17",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "author": "Eduard Kizmann <kizmann@protonmail.ch>",
@@ -16,6 +16,8 @@ export default class Map
16
16
 
17
17
  cluster = null;
18
18
 
19
+ clusterFilter = null;
20
+
19
21
  clusterOptions = {};
20
22
 
21
23
  static hideMarkers = true;
@@ -100,7 +102,7 @@ export default class Map
100
102
  return this;
101
103
  }
102
104
 
103
- clusterMarkers(options = {}, allowCreate = true)
105
+ clusterMarkers(options = {}, filter = null, allowCreate = true)
104
106
  {
105
107
  if ( ! this.cluster && ! allowCreate ) {
106
108
  return;
@@ -115,11 +117,22 @@ export default class Map
115
117
  }
116
118
 
117
119
  if ( this.cluster ) {
118
- this.cluster.clearMarkers()
120
+ this.cluster.clearMarkers();
121
+ }
122
+
123
+ if ( Any.isFunction(filter) ) {
124
+ this.clusterFilter = filter;
119
125
  }
120
126
 
121
127
  let markers = Arr.filter(this.markers, (item) => {
122
- return this.getMarkerVisibility(item.key);
128
+
129
+ let visible = this.getMarkerVisibility(item.key);
130
+
131
+ if ( ! Any.isFunction(this.clusterFilter) ) {
132
+ return visible;
133
+ }
134
+
135
+ return visible && this.clusterFilter.call(this, item);
123
136
  });
124
137
 
125
138
  this.cluster = new global.MarkerClusterer(this.map, Arr.each(markers, (item) => item.marker),
@@ -365,7 +378,7 @@ export default class Map
365
378
 
366
379
  Obj.set(this.markers, key, item);
367
380
 
368
- this.clusterMarkers(this.clusterOptions, false);
381
+ this.clusterMarkers(this.clusterOptions, null, false);
369
382
 
370
383
  if ( ! Obj.has(options, 'html') ) {
371
384
  return Obj.get(this.markers, key);
@@ -453,7 +466,7 @@ export default class Map
453
466
 
454
467
  Obj.each(markers, (item) => this.showMarker(item.key));
455
468
 
456
- this.clusterMarkers(this.clusterOptions, false);
469
+ this.clusterMarkers(this.clusterOptions, null, false);
457
470
 
458
471
  return this;
459
472
  }
@@ -91,6 +91,10 @@ export class Num
91
91
 
92
92
  static format(num, decimal = '.', thousand = ',', fixed = null)
93
93
  {
94
+ if ( num === null ) {
95
+ return null;
96
+ }
97
+
94
98
  let value = num.toString();
95
99
 
96
100
  if ( fixed !== null && fixed !== - 1 ) {
@@ -98,7 +102,7 @@ export class Num
98
102
  }
99
103
 
100
104
  let totals = value.replace(/\.[0-9]+$/, ''),
101
- minals = value.replace(/^[0-9]+\./, '');
105
+ minals = value.replace(/^[0-9\-]+\./, '');
102
106
 
103
107
  let splits = Arr.reduce(totals.split('').reverse(), (result, val, key) => {
104
108