@kizmann/pico-js 1.0.13 → 2.0.0

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 (125) hide show
  1. package/README.md +27 -7
  2. package/dist/pico-js.browser.js +2 -0
  3. package/dist/pico-js.browser.js.map +1 -0
  4. package/dist/pico-js.esm.js +2 -0
  5. package/dist/pico-js.esm.js.map +1 -0
  6. package/package.json +20 -7
  7. package/src/dom/DomAttribute.js +374 -0
  8. package/src/dom/DomBuilder.js +152 -0
  9. package/src/dom/DomEvent.js +253 -0
  10. package/src/dom/DomFinder.js +669 -0
  11. package/src/dom/DomForm.js +57 -0
  12. package/src/dom/DomGlobal.js +193 -0
  13. package/src/dom/DomInview.js +332 -0
  14. package/src/dom/DomMeta.js +66 -0
  15. package/src/dom/DomObserver.js +57 -0
  16. package/src/dom/DomRectangle.js +657 -0
  17. package/src/format/FormatFile.js +54 -0
  18. package/src/format/FormatOption.js +108 -0
  19. package/src/format/FormatParam.js +107 -0
  20. package/src/format/FormatParser.js +156 -0
  21. package/src/format/FormatUrl.js +75 -0
  22. package/src/index.browser.js +10 -0
  23. package/src/index.esm.js +138 -0
  24. package/src/now/NowDefault.js +533 -0
  25. package/src/now/NowFormat.js +196 -0
  26. package/src/now/NowGrid.js +251 -0
  27. package/src/now/NowHuman.js +118 -0
  28. package/src/now/NowMatch.js +175 -0
  29. package/src/now/NowRange.js +70 -0
  30. package/src/now/NowWalker.js +544 -0
  31. package/src/tool/scope.js +103 -0
  32. package/src/utils/Array.js +986 -0
  33. package/src/utils/Cookie.js +184 -0
  34. package/src/utils/Data.js +200 -0
  35. package/src/utils/Dom.js +208 -0
  36. package/src/utils/Event.js +140 -0
  37. package/src/utils/Format.js +62 -0
  38. package/src/utils/Hash.js +164 -0
  39. package/src/utils/Locale.js +229 -0
  40. package/src/utils/Mixed.js +887 -0
  41. package/src/utils/Now.js +234 -0
  42. package/src/utils/Number.js +238 -0
  43. package/src/utils/Object.js +655 -0
  44. package/src/utils/Route.js +67 -0
  45. package/src/utils/Runner.js +327 -0
  46. package/src/utils/String.js +618 -0
  47. package/src/{library/element.js → wip/Element.js} +90 -16
  48. package/src/{library/map.js → wip/Map.js} +256 -40
  49. package/types/dom/DomAttribute.d.ts +137 -0
  50. package/types/dom/DomBuilder.d.ts +67 -0
  51. package/types/dom/DomEvent.d.ts +103 -0
  52. package/types/dom/DomFinder.d.ts +321 -0
  53. package/types/dom/DomForm.d.ts +21 -0
  54. package/types/dom/DomGlobal.d.ts +79 -0
  55. package/types/dom/DomInview.d.ts +114 -0
  56. package/types/dom/DomMeta.d.ts +29 -0
  57. package/types/dom/DomObserver.d.ts +21 -0
  58. package/types/dom/DomRectangle.d.ts +270 -0
  59. package/types/format/FormatFile.d.ts +18 -0
  60. package/types/format/FormatOption.d.ts +40 -0
  61. package/types/format/FormatParam.d.ts +39 -0
  62. package/types/format/FormatParser.d.ts +46 -0
  63. package/types/format/FormatUrl.d.ts +17 -0
  64. package/types/index.browser.d.ts +1 -0
  65. package/types/index.esm.d.ts +52 -0
  66. package/types/now/NowDefault.d.ts +183 -0
  67. package/types/now/NowFormat.d.ts +70 -0
  68. package/types/now/NowGrid.d.ts +107 -0
  69. package/types/now/NowHuman.d.ts +37 -0
  70. package/types/now/NowMatch.d.ts +108 -0
  71. package/types/now/NowRange.d.ts +21 -0
  72. package/types/now/NowWalker.d.ts +301 -0
  73. package/types/tool/scope.d.ts +24 -0
  74. package/types/utils/Array.d.ts +480 -0
  75. package/types/utils/Cookie.d.ts +60 -0
  76. package/types/utils/Data.d.ts +91 -0
  77. package/types/utils/Dom.d.ts +138 -0
  78. package/types/utils/Event.d.ts +58 -0
  79. package/types/utils/Format.d.ts +37 -0
  80. package/types/utils/Hash.d.ts +81 -0
  81. package/types/utils/Locale.d.ts +115 -0
  82. package/types/utils/Mixed.d.ts +469 -0
  83. package/types/utils/Now.d.ts +125 -0
  84. package/types/utils/Number.d.ts +127 -0
  85. package/types/utils/Object.d.ts +255 -0
  86. package/types/utils/Route.d.ts +37 -0
  87. package/types/utils/Runner.d.ts +139 -0
  88. package/types/utils/String.d.ts +330 -0
  89. package/types/wip/Element.d.ts +119 -0
  90. package/types/wip/Map.d.ts +254 -0
  91. package/dist/.ignore.js +0 -0
  92. package/dist/pico-js.js +0 -2
  93. package/dist/pico-js.js.map +0 -1
  94. package/src/element/default.js +0 -46
  95. package/src/element/example.js +0 -58
  96. package/src/index.js +0 -90
  97. package/src/library/cookie.js +0 -123
  98. package/src/library/data.js +0 -111
  99. package/src/library/event.js +0 -91
  100. package/src/library/locale.js +0 -84
  101. package/src/library/queue.js +0 -64
  102. package/src/library/route.js +0 -28
  103. package/src/utility/any.js +0 -369
  104. package/src/utility/array.js +0 -410
  105. package/src/utility/dom.js +0 -1425
  106. package/src/utility/now.js +0 -544
  107. package/src/utility/number.js +0 -128
  108. package/src/utility/object.js +0 -429
  109. package/src/utility/string.js +0 -328
  110. package/types/index.d.ts +0 -77
  111. package/types/library/cookie.d.ts +0 -10
  112. package/types/library/data.d.ts +0 -15
  113. package/types/library/element.d.ts +0 -22
  114. package/types/library/event.d.ts +0 -13
  115. package/types/library/locale.d.ts +0 -14
  116. package/types/library/map.d.ts +0 -43
  117. package/types/library/queue.d.ts +0 -18
  118. package/types/library/route.d.ts +0 -11
  119. package/types/utility/any.d.ts +0 -35
  120. package/types/utility/array.d.ts +0 -46
  121. package/types/utility/dom.d.ts +0 -101
  122. package/types/utility/now.d.ts +0 -79
  123. package/types/utility/number.d.ts +0 -17
  124. package/types/utility/object.d.ts +0 -29
  125. package/types/utility/string.d.ts +0 -26
@@ -1,10 +1,10 @@
1
- import { Obj, Arr, Any, Dom, Event, UUID } from "../index.js";
1
+ import { go, Obj, Arr, Mix, Dom, Event, Hash } from "#src/index.esm.js";
2
2
 
3
3
  /**
4
4
  * @const {object} google
5
5
  */
6
6
 
7
- export default class Map
7
+ export class PicoMap
8
8
  {
9
9
  map = null;
10
10
 
@@ -24,9 +24,17 @@ export default class Map
24
24
 
25
25
  static closeInfoWindows = true;
26
26
 
27
+ /**
28
+ * Create map instance
29
+ *
30
+ * @example new Map("#map", { lat: 0, lng: 0 })
31
+ *
32
+ * @param {any} el Target element
33
+ * @param {any} [options] Map options
34
+ */
27
35
  constructor(el, options = {})
28
36
  {
29
- if ( ! window.google ) {
37
+ if ( ! globalThis.google ) {
30
38
  throw new Error('Google Maps is required for pi.Map');
31
39
  }
32
40
 
@@ -39,9 +47,17 @@ export default class Map
39
47
  options = Obj.assign({ gestureHandling: 'cooperative', scrollwheel: null, zoom: 12, center },
40
48
  Obj.except(options, ['lat', 'lng']));
41
49
 
42
- this.map = new window.google.maps.Map(Dom.find(el).get(0), options)
50
+ this.map = new globalThis.google.maps.Map(Dom.find(el).get(0), options)
43
51
  }
44
52
 
53
+ /**
54
+ * Set global map style
55
+ *
56
+ * @example Map.setMapStyle(style)
57
+ *
58
+ * @param {Array<any>} [style] Style array
59
+ * @returns {this} Current class
60
+ */
45
61
  static setMapStyle(style = [])
46
62
  {
47
63
  Map.mapStyle = style;
@@ -49,9 +65,19 @@ export default class Map
49
65
  return this;
50
66
  }
51
67
 
68
+ /**
69
+ * Set marker style
70
+ *
71
+ * @example Map.setMarkerStyle("default", { default: "icon.png" })
72
+ *
73
+ * @param {string} key Style key
74
+ * @param {any} [style] Style options
75
+ * @param {any} [extra] Extra options
76
+ * @returns {this} Current class
77
+ */
52
78
  static setMarkerStyle(key, style = {}, extra = {})
53
79
  {
54
- if ( ! window.google ) {
80
+ if ( ! globalThis.google ) {
55
81
  throw new Error('Google Maps is required for pi.Map');
56
82
  }
57
83
 
@@ -70,13 +96,13 @@ export default class Map
70
96
  let final = {};
71
97
 
72
98
  // Marker size
73
- let size = new window.google.maps.Size(style.width, style.height);
99
+ let size = new globalThis.google.maps.Size(style.width, style.height);
74
100
 
75
101
  // Point position
76
- let origin = new window.google.maps.Point(0, 0);
102
+ let origin = new globalThis.google.maps.Point(0, 0);
77
103
 
78
104
  // Point position
79
- let anchor = new window.google.maps.Point(style.width / 2, style.height);
105
+ let anchor = new globalThis.google.maps.Point(style.width / 2, style.height);
80
106
 
81
107
  final.default = {
82
108
  url: style.default, size: size, origin: origin, anchor: anchor, scaledSize: size
@@ -107,13 +133,23 @@ export default class Map
107
133
  return this;
108
134
  }
109
135
 
136
+ /**
137
+ * Cluster map markers
138
+ *
139
+ * @example map.clusterMarkers()
140
+ *
141
+ * @param {any} [options] Cluster options
142
+ * @param {any} [filter] Marker filter
143
+ * @param {boolean} [allowCreate] Create cluster
144
+ * @returns {void} No return value
145
+ */
110
146
  clusterMarkers(options = {}, filter = null, allowCreate = true)
111
147
  {
112
148
  if ( ! this.cluster && ! allowCreate ) {
113
149
  return;
114
150
  }
115
151
 
116
- if ( typeof window.MarkerClusterer === "undefined" ) {
152
+ if ( typeof globalThis.MarkerClusterer === "undefined" ) {
117
153
  return console.error('Google Maps Cluster library not laoded!');
118
154
  }
119
155
 
@@ -125,7 +161,7 @@ export default class Map
125
161
  this.cluster.clearMarkers();
126
162
  }
127
163
 
128
- if ( Any.isFunction(filter) ) {
164
+ if ( Mix.isFunction(filter) ) {
129
165
  this.clusterFilter = filter;
130
166
  }
131
167
 
@@ -133,26 +169,35 @@ export default class Map
133
169
 
134
170
  let visible = this.getMarkerVisibility(item.key);
135
171
 
136
- if ( ! Any.isFunction(this.clusterFilter) ) {
172
+ if ( ! Mix.isFunction(this.clusterFilter) ) {
137
173
  return visible;
138
174
  }
139
175
 
140
176
  return visible && this.clusterFilter.call(this, item);
141
177
  });
142
178
 
143
- this.cluster = new window.MarkerClusterer(this.map, Arr.each(markers, (item) => item.marker),
179
+ this.cluster = new globalThis.MarkerClusterer(this.map, Arr.each(markers, (item) => item.marker),
144
180
  this.clusterOptions = options);
145
181
  }
146
182
 
183
+ /**
184
+ * Apply style to marker
185
+ *
186
+ * @example map.styleMarker("m1", "hover")
187
+ *
188
+ * @param {string} key Marker key
189
+ * @param {any} [type] Style type
190
+ * @returns {void} No return value
191
+ */
147
192
  styleMarker(key, type = null)
148
193
  {
149
194
  let item = Obj.get(this.markers, key);
150
195
 
151
- if ( Any.isEmpty(item) ) {
196
+ if ( Mix.isEmpty(item) ) {
152
197
  return console.error(`Marker "${key}" not found`);
153
198
  }
154
199
 
155
- if ( Any.isEmpty(type) ) {
200
+ if ( Mix.isEmpty(type) ) {
156
201
  type = this.getInfoVisibility(key) ? 'active' : 'default';
157
202
  }
158
203
 
@@ -163,38 +208,72 @@ export default class Map
163
208
  item.marker.setIcon(Obj.get(Map.markerStyles, [item.style, type]));
164
209
  }
165
210
 
211
+ /**
212
+ * Get marker by key
213
+ *
214
+ * @example map.getMarker("m1")
215
+ *
216
+ * @param {string} key Marker key
217
+ * @returns {any} Marker object
218
+ */
166
219
  getMarker(key)
167
220
  {
168
221
  return Obj.get(this.markers, key);
169
222
  }
170
223
 
224
+ /**
225
+ * Check if marker is visible
226
+ *
227
+ * @example map.getMarkerVisibility("m1") // => true
228
+ *
229
+ * @param {string} key Marker key
230
+ * @param {boolean} [fallback] Fallback value
231
+ * @returns {boolean} Visibility state
232
+ */
171
233
  getMarkerVisibility(key, fallback = false)
172
234
  {
173
235
  let item = Obj.get(this.markers, key);
174
236
 
175
- if ( Any.isEmpty(item) ) {
237
+ if ( Mix.isEmpty(item) ) {
176
238
  return fallback;
177
239
  }
178
240
 
179
241
  return item.marker.getVisible();
180
242
  }
181
243
 
244
+ /**
245
+ * Get marker position
246
+ *
247
+ * @example map.getMarkerPositon("m1") // => LatLng
248
+ *
249
+ * @param {string} key Marker key
250
+ * @param {any} [fallback] Fallback value
251
+ * @returns {any} Position object
252
+ */
182
253
  getMarkerPositon(key, fallback = null)
183
254
  {
184
255
  let item = Obj.get(this.markers, key);
185
256
 
186
- if ( Any.isEmpty(item) ) {
257
+ if ( Mix.isEmpty(item) ) {
187
258
  return fallback;
188
259
  }
189
260
 
190
261
  return item.marker.getPosition();
191
262
  }
192
263
 
264
+ /**
265
+ * Toggle marker visibility
266
+ *
267
+ * @example map.toggleMarker("m1")
268
+ *
269
+ * @param {string} key Marker key
270
+ * @returns {boolean|void} Visibility state
271
+ */
193
272
  toggleMarker(key)
194
273
  {
195
274
  let item = Obj.get(this.markers, key);
196
275
 
197
- if ( Any.isEmpty(item) ) {
276
+ if ( Mix.isEmpty(item) ) {
198
277
  return console.error(`Marker "${key}" not found`);
199
278
  }
200
279
 
@@ -205,11 +284,19 @@ export default class Map
205
284
  return this.showMarker(key);
206
285
  }
207
286
 
287
+ /**
288
+ * Show marker on map
289
+ *
290
+ * @example map.showMarker("m1")
291
+ *
292
+ * @param {string} key Marker key
293
+ * @returns {boolean|void} Previous state
294
+ */
208
295
  showMarker(key)
209
296
  {
210
297
  let item = Obj.get(this.markers, key);
211
298
 
212
- if ( Any.isEmpty(item) ) {
299
+ if ( Mix.isEmpty(item) ) {
213
300
  return console.error(`Marker "${key}" not found`);
214
301
  }
215
302
 
@@ -222,11 +309,19 @@ export default class Map
222
309
  return hidden;
223
310
  }
224
311
 
312
+ /**
313
+ * Hide marker on map
314
+ *
315
+ * @example map.hideMarker("m1")
316
+ *
317
+ * @param {string} key Marker key
318
+ * @returns {boolean|void} Previous state
319
+ */
225
320
  hideMarker(key)
226
321
  {
227
322
  let item = Obj.get(this.markers, key);
228
323
 
229
- if ( Any.isEmpty(item) ) {
324
+ if ( Mix.isEmpty(item) ) {
230
325
  return console.error(`Marker "${key}" not found`);
231
326
  }
232
327
 
@@ -241,11 +336,19 @@ export default class Map
241
336
  return visible;
242
337
  }
243
338
 
339
+ /**
340
+ * Marker hover enter
341
+ *
342
+ * @example map.enterMarker("m1")
343
+ *
344
+ * @param {string} key Marker key
345
+ * @returns {this|void} Current instance
346
+ */
244
347
  enterMarker(key)
245
348
  {
246
349
  let item = Obj.get(this.markers, key);
247
350
 
248
- if ( Any.isEmpty(item) ) {
351
+ if ( Mix.isEmpty(item) ) {
249
352
  return console.error(`Marker "${key}" not found`);
250
353
  }
251
354
 
@@ -260,11 +363,19 @@ export default class Map
260
363
  return this;
261
364
  }
262
365
 
366
+ /**
367
+ * Marker hover leave
368
+ *
369
+ * @example map.leaveMarker("m1")
370
+ *
371
+ * @param {string} key Marker key
372
+ * @returns {this|void} Current instance
373
+ */
263
374
  leaveMarker(key)
264
375
  {
265
376
  let item = Obj.get(this.markers, key);
266
377
 
267
- if ( Any.isEmpty(item) ) {
378
+ if ( Mix.isEmpty(item) ) {
268
379
  return console.error(`Marker "${key}" not found`);
269
380
  }
270
381
 
@@ -279,22 +390,39 @@ export default class Map
279
390
  return this;
280
391
  }
281
392
 
393
+ /**
394
+ * Check if info is open
395
+ *
396
+ * @example map.getInfoVisibility("m1") // => true
397
+ *
398
+ * @param {string} key Marker key
399
+ * @param {boolean} [fallback] Fallback value
400
+ * @returns {boolean} Visibility state
401
+ */
282
402
  getInfoVisibility(key, fallback = false)
283
403
  {
284
404
  let item = Obj.get(this.markers, key);
285
405
 
286
- if ( Any.isEmpty(item) || ! Obj.has(item, 'info') ) {
406
+ if ( Mix.isEmpty(item) || ! Obj.has(item, 'info') ) {
287
407
  return fallback;
288
408
  }
289
409
 
290
410
  return !! item.info.getMap();
291
411
  }
292
412
 
413
+ /**
414
+ * Toggle info window
415
+ *
416
+ * @example map.toggleInfo("m1")
417
+ *
418
+ * @param {string} key Marker key
419
+ * @returns {boolean|void} Visibility state
420
+ */
293
421
  toggleInfo(key)
294
422
  {
295
423
  let item = Obj.get(this.markers, key);
296
424
 
297
- if ( Any.isEmpty(item) ) {
425
+ if ( Mix.isEmpty(item) ) {
298
426
  return console.error(`Marker "${key}" not found`);
299
427
  }
300
428
 
@@ -305,11 +433,19 @@ export default class Map
305
433
  return this.openInfo(key);
306
434
  }
307
435
 
436
+ /**
437
+ * Open info window
438
+ *
439
+ * @example map.openInfo("m1")
440
+ *
441
+ * @param {string} key Marker key
442
+ * @returns {boolean|void} Previous state
443
+ */
308
444
  openInfo(key)
309
445
  {
310
446
  let item = Obj.get(this.markers, key);
311
447
 
312
- if ( Any.isEmpty(item) ) {
448
+ if ( Mix.isEmpty(item) ) {
313
449
  return console.error(`InfoWindow "${key}" not found`);
314
450
  }
315
451
 
@@ -320,14 +456,14 @@ export default class Map
320
456
  let hidden = ! item.info.getMap();
321
457
 
322
458
  if ( Map.closeInfoWindows ) {
323
- Obj.each(Any.keys(this.markers), this.closeInfo.bind(this));
459
+ Obj.each(Mix.keys(this.markers), this.closeInfo.bind(this));
324
460
  }
325
461
 
326
462
  if ( hidden ) {
327
463
  item.info.open(this.map, item.marker);
328
464
  }
329
465
 
330
- if ( Any.isFunction(item.onOpen) ) {
466
+ if ( Mix.isFunction(item.onOpen) ) {
331
467
  item.onOpen(item);
332
468
  }
333
469
 
@@ -336,11 +472,19 @@ export default class Map
336
472
  return hidden;
337
473
  }
338
474
 
475
+ /**
476
+ * Close info window
477
+ *
478
+ * @example map.closeInfo("m1")
479
+ *
480
+ * @param {string} key Marker key
481
+ * @returns {boolean|void} Previous state
482
+ */
339
483
  closeInfo(key)
340
484
  {
341
485
  let item = Obj.get(this.markers, key);
342
486
 
343
- if ( Any.isEmpty(item) ) {
487
+ if ( Mix.isEmpty(item) ) {
344
488
  return console.error(`InfoWindow "${key}" not found`);
345
489
  }
346
490
 
@@ -354,7 +498,7 @@ export default class Map
354
498
  item.info.close();
355
499
  }
356
500
 
357
- if ( Any.isFunction(item.onClose) ) {
501
+ if ( Mix.isFunction(item.onClose) ) {
358
502
  item.onClose(item);
359
503
  }
360
504
 
@@ -363,10 +507,19 @@ export default class Map
363
507
  return visible;
364
508
  }
365
509
 
510
+ /**
511
+ * Create map marker
512
+ *
513
+ * @example map.createMarker("m1", { lat: 0, lng: 0 })
514
+ *
515
+ * @param {any} [key] Marker key
516
+ * @param {any} [options] Marker options
517
+ * @returns {any} Marker object
518
+ */
366
519
  createMarker(key = null, options = {})
367
520
  {
368
- if ( Any.isEmpty(key) ) {
369
- key = UUID();
521
+ if ( Mix.isEmpty(key) ) {
522
+ key = Hash.uuid();
370
523
  }
371
524
 
372
525
  let item = { key };
@@ -391,7 +544,7 @@ export default class Map
391
544
  item.style = options.style;
392
545
  }
393
546
 
394
- item.marker = new window.google.maps.Marker(options);
547
+ item.marker = new globalThis.google.maps.Marker(options);
395
548
 
396
549
  if ( !options.visible ) {
397
550
  item.marker.setVisible(false);
@@ -422,7 +575,7 @@ export default class Map
422
575
  // Add marker default style
423
576
  item.marker.addListener('mouseout', () => this.leaveMarker(key));
424
577
 
425
- item.info = new window.google.maps.InfoWindow({
578
+ item.info = new globalThis.google.maps.InfoWindow({
426
579
  content: '<div class="gw-i-html">' + Obj.get(options, 'html') + '</div>'
427
580
  });
428
581
 
@@ -437,17 +590,35 @@ export default class Map
437
590
  return Obj.get(this.markers, key);
438
591
  }
439
592
 
593
+ /**
594
+ * Set marker position
595
+ *
596
+ * @example map.setMarkerPosition("m1", { lat: 0, lng: 0 })
597
+ *
598
+ * @param {string} key Marker key
599
+ * @param {any} [options] Position options
600
+ * @returns {void} No return value
601
+ */
440
602
  setMarkerPosition(key, options = {})
441
603
  {
442
604
  let item = Obj.get(this.markers, key);
443
605
 
444
- if ( Any.isEmpty(item) ) {
606
+ if ( Mix.isEmpty(item) ) {
445
607
  return console.error(`Marker "${key}" not found`);
446
608
  }
447
609
 
448
610
  item.marker.setPosition(options);
449
611
  }
450
612
 
613
+ /**
614
+ * Set marker by address
615
+ *
616
+ * @example map.setMarkerByAddress("m1", "Address")
617
+ *
618
+ * @param {string} key Marker key
619
+ * @param {any} address Search address
620
+ * @returns {Promise<any>} Response promise
621
+ */
451
622
  setMarkerByAddress(key, address)
452
623
  {
453
624
  return this.getLocationByAddress(address, (res) => {
@@ -455,9 +626,18 @@ export default class Map
455
626
  });
456
627
  }
457
628
 
629
+ /**
630
+ * Get location by address
631
+ *
632
+ * @example map.getLocationByAddress("Address")
633
+ *
634
+ * @param {any} address Search address
635
+ * @param {function} [callback] Success callback
636
+ * @returns {Promise<any>} Response promise
637
+ */
458
638
  getLocationByAddress(address, callback = null)
459
639
  {
460
- let geocoderService = new window.google.maps.Geocoder();
640
+ let geocoderService = new globalThis.google.maps.Geocoder();
461
641
 
462
642
  let geocoderPromise = (resolve, reject) => {
463
643
 
@@ -480,16 +660,24 @@ export default class Map
480
660
  return new Promise(geocoderPromise);
481
661
  }
482
662
 
663
+ /**
664
+ * Show markers on map
665
+ *
666
+ * @example map.showMarkers()
667
+ *
668
+ * @param {any} [filter] Marker filter
669
+ * @returns {this} Current instance
670
+ */
483
671
  showMarkers(filter = null)
484
672
  {
485
673
  let markers = this.markers;
486
674
 
487
- if ( ! Any.isEmpty(filter) ) {
675
+ if ( ! Mix.isEmpty(filter) ) {
488
676
  markers = Obj.filter(this.markers, filter);
489
677
  }
490
678
 
491
679
  if ( Map.hideMarkers ) {
492
- Obj.each(Any.keys(this.markers), this.hideMarker.bind(this));
680
+ Obj.each(Mix.keys(this.markers), this.hideMarker.bind(this));
493
681
  }
494
682
 
495
683
  Obj.each(markers, (item) => this.showMarker(item.key));
@@ -499,15 +687,23 @@ export default class Map
499
687
  return this;
500
688
  }
501
689
 
690
+ /**
691
+ * Get marker boundary
692
+ *
693
+ * @example map.getMarkerBoundry() // => LatLngBounds
694
+ *
695
+ * @param {any} [filter] Marker filter
696
+ * @returns {any} Boundary object
697
+ */
502
698
  getMarkerBoundry(filter = null)
503
699
  {
504
700
  let markers = this.markers;
505
701
 
506
- if ( ! Any.isEmpty(filter) ) {
702
+ if ( ! Mix.isEmpty(filter) ) {
507
703
  markers = Obj.filter(this.markers, filter);
508
704
  }
509
705
 
510
- let boundry = new window.google.maps.LatLngBounds();
706
+ let boundry = new globalThis.google.maps.LatLngBounds();
511
707
 
512
708
  Obj.each(markers, (item) => {
513
709
  if ( item.marker.getVisible() ) {
@@ -518,6 +714,16 @@ export default class Map
518
714
  return boundry;
519
715
  }
520
716
 
717
+ /**
718
+ * Focus markers on map
719
+ *
720
+ * @example map.focusMarkers()
721
+ *
722
+ * @param {any} [filter] Marker filter
723
+ * @param {number} [maxZoom] Max zoom level
724
+ * @param {number} [boundSpace] Viewport space
725
+ * @returns {this} Current instance
726
+ */
521
727
  focusMarkers(filter = null, maxZoom = 14, boundSpace = 15)
522
728
  {
523
729
  let boundry = this.getMarkerBoundry(filter);
@@ -535,13 +741,21 @@ export default class Map
535
741
  return this;
536
742
  }
537
743
 
744
+ /**
745
+ * Render directions on map
746
+ *
747
+ * @example map.renderDirections({ origin: "A", destination: "B" })
748
+ *
749
+ * @param {any} options Render options
750
+ * @returns {Promise<any>} Response promise
751
+ */
538
752
  renderDirections(options)
539
753
  {
540
754
  // Get directions service
541
- let directionsService = new window.google.maps.DirectionsService();
755
+ let directionsService = new globalThis.google.maps.DirectionsService();
542
756
 
543
757
  // Get directions renderer
544
- let directionsRenderer = new window.google.maps.DirectionsRenderer();
758
+ let directionsRenderer = new globalThis.google.maps.DirectionsRenderer();
545
759
 
546
760
  if ( ! Obj.has(options, 'map') ) {
547
761
  options.map = this.map;
@@ -582,3 +796,5 @@ export default class Map
582
796
  }
583
797
 
584
798
  }
799
+
800
+ export default PicoMap;