@kizmann/pico-js 2.0.8 → 2.0.10
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/dist/pico-js.browser.js +1 -1
- package/dist/pico-js.browser.js.map +1 -1
- package/dist/pico-js.esm.js +1 -1
- package/dist/pico-js.esm.js.map +1 -1
- package/package.json +4 -6
- package/src/dom/{DomAttribute.js → DomAttribute.ts} +40 -63
- package/src/dom/{DomBuilder.js → DomBuilder.ts} +27 -44
- package/src/dom/{DomEvent.js → DomEvent.ts} +74 -78
- package/src/dom/{DomFinder.js → DomFinder.ts} +89 -129
- package/src/dom/DomForm.ts +38 -0
- package/src/dom/{DomGlobal.js → DomGlobal.ts} +34 -51
- package/src/dom/{DomInview.js → DomInview.ts} +37 -57
- package/src/dom/DomMeta.ts +48 -0
- package/src/dom/DomObserver.ts +17 -0
- package/src/dom/{DomPopover.js → DomPopover.ts} +20 -39
- package/src/dom/{DomRectangle.js → DomRectangle.ts} +67 -88
- package/src/format/{FormatFile.js → FormatFile.ts} +12 -23
- package/src/format/{FormatOption.js → FormatOption.ts} +15 -24
- package/src/format/{FormatParam.js → FormatParam.ts} +14 -25
- package/src/format/{FormatParser.js → FormatParser.ts} +29 -39
- package/src/format/{FormatUrl.js → FormatUrl.ts} +9 -21
- package/src/index.browser.ts +32 -0
- package/src/index.esm.ts +64 -0
- package/src/now/{NowDefault.js → NowDefault.ts} +86 -121
- package/src/now/{NowFormat.js → NowFormat.ts} +23 -28
- package/src/now/{NowGrid.js → NowGrid.ts} +41 -58
- package/src/now/{NowHuman.js → NowHuman.ts} +18 -27
- package/src/now/{NowMatch.js → NowMatch.ts} +22 -28
- package/src/now/{NowRange.js → NowRange.ts} +13 -22
- package/src/now/{NowWalker.js → NowWalker.ts} +65 -71
- package/src/tool/{scope.js → scope.ts} +41 -11
- package/src/utils/{Array.js → Array.ts} +146 -160
- package/src/utils/{Cookie.js → Cookie.ts} +15 -12
- package/src/utils/{Data.js → Data.ts} +17 -17
- package/src/utils/Dom.ts +204 -0
- package/src/utils/Format.ts +48 -0
- package/src/utils/{Hash.js → Hash.ts} +20 -20
- package/src/utils/{Locale.js → Locale.ts} +22 -22
- package/src/utils/{Mixed.js → Mixed.ts} +70 -58
- package/src/utils/{Now.js → Now.ts} +68 -69
- package/src/utils/{Number.js → Number.ts} +34 -36
- package/src/utils/{Object.js → Object.ts} +68 -122
- package/src/utils/{Route.js → Route.ts} +11 -9
- package/src/utils/{Runner.js → Runner.ts} +65 -47
- package/src/utils/{Signal.js → Signal.ts} +35 -22
- package/src/utils/{String.js → String.ts} +79 -69
- package/src/wip/{Element.js → Element.ts} +2 -2
- package/src/wip/{Map.js → Map.ts} +131 -101
- package/types/dom/DomAttribute.d.ts +16 -27
- package/types/dom/DomBuilder.d.ts +6 -9
- package/types/dom/DomEvent.d.ts +19 -25
- package/types/dom/DomFinder.d.ts +35 -58
- package/types/dom/DomForm.d.ts +7 -10
- package/types/dom/DomGlobal.d.ts +8 -15
- package/types/dom/DomInview.d.ts +9 -19
- package/types/dom/DomMeta.d.ts +9 -16
- package/types/dom/DomObserver.d.ts +4 -8
- package/types/dom/DomPopover.d.ts +8 -11
- package/types/dom/DomRectangle.d.ts +21 -40
- package/types/format/FormatFile.d.ts +5 -8
- package/types/format/FormatOption.d.ts +6 -8
- package/types/format/FormatParam.d.ts +6 -9
- package/types/format/FormatParser.d.ts +10 -18
- package/types/format/FormatUrl.d.ts +5 -8
- package/types/index.esm.d.ts +25 -37
- package/types/now/NowDefault.d.ts +30 -99
- package/types/now/NowFormat.d.ts +8 -21
- package/types/now/NowGrid.d.ts +24 -46
- package/types/now/NowHuman.d.ts +10 -11
- package/types/now/NowMatch.d.ts +6 -4
- package/types/now/NowRange.d.ts +5 -8
- package/types/now/NowWalker.d.ts +6 -4
- package/types/tool/scope.d.ts +11 -3
- package/types/utils/Array.d.ts +83 -104
- package/types/utils/Cookie.d.ts +11 -8
- package/types/utils/Data.d.ts +7 -7
- package/types/utils/Dom.d.ts +63 -96
- package/types/utils/Format.d.ts +15 -28
- package/types/utils/Hash.d.ts +21 -21
- package/types/utils/Locale.d.ts +10 -10
- package/types/utils/Mixed.d.ts +18 -32
- package/types/utils/Now.d.ts +51 -56
- package/types/utils/Number.d.ts +9 -20
- package/types/utils/Object.d.ts +21 -36
- package/types/utils/Route.d.ts +5 -2
- package/types/utils/Runner.d.ts +41 -24
- package/types/utils/Signal.d.ts +16 -16
- package/types/utils/String.d.ts +40 -76
- package/src/dom/DomForm.js +0 -59
- package/src/dom/DomMeta.js +0 -68
- package/src/dom/DomObserver.js +0 -38
- package/src/index.browser.js +0 -36
- package/src/index.esm.js +0 -80
- package/src/utils/Dom.js +0 -214
- package/src/utils/Format.js +0 -62
- package/types/wip/Element.d.ts +0 -119
- package/types/wip/Map.d.ts +0 -254
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Obj, Arr, Mix, Dom, Signal, Hash } from "../index.esm.ts";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @const {object} google
|
|
@@ -6,23 +6,51 @@ import { go, Obj, Arr, Mix, Dom, Event, Hash } from "#src/index.esm.js";
|
|
|
6
6
|
|
|
7
7
|
export class PicoMap
|
|
8
8
|
{
|
|
9
|
-
map = null;
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
/**
|
|
11
|
+
* @type {any[]}
|
|
12
|
+
*/
|
|
13
|
+
static mapStyle : any[] = [];
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @type {object}
|
|
17
|
+
*/
|
|
18
|
+
static markerStyles : any = {};
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @type {boolean}
|
|
22
|
+
*/
|
|
23
|
+
static hideMarkers : boolean = true;
|
|
16
24
|
|
|
17
|
-
|
|
25
|
+
/**
|
|
26
|
+
* @type {boolean}
|
|
27
|
+
*/
|
|
28
|
+
static closeInfoWindows : boolean = true;
|
|
18
29
|
|
|
19
|
-
|
|
30
|
+
/**
|
|
31
|
+
* @type {any}
|
|
32
|
+
*/
|
|
33
|
+
map : any = null;
|
|
20
34
|
|
|
21
|
-
|
|
35
|
+
/**
|
|
36
|
+
* @type {any}
|
|
37
|
+
*/
|
|
38
|
+
markers : any = {};
|
|
22
39
|
|
|
23
|
-
|
|
40
|
+
/**
|
|
41
|
+
* @type {any}
|
|
42
|
+
*/
|
|
43
|
+
cluster : any = null;
|
|
24
44
|
|
|
25
|
-
|
|
45
|
+
/**
|
|
46
|
+
* @type {any}
|
|
47
|
+
*/
|
|
48
|
+
clusterFilter : any = null;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @type {any}
|
|
52
|
+
*/
|
|
53
|
+
clusterOptions : any = {};
|
|
26
54
|
|
|
27
55
|
/**
|
|
28
56
|
* Create map instance
|
|
@@ -32,16 +60,16 @@ export class PicoMap
|
|
|
32
60
|
* @param {any} el Target element
|
|
33
61
|
* @param {any} [options] Map options
|
|
34
62
|
*/
|
|
35
|
-
constructor(el, options = {})
|
|
63
|
+
constructor(el : any, options : any = {})
|
|
36
64
|
{
|
|
37
|
-
if ( !
|
|
65
|
+
if ( !globalThis.google ) {
|
|
38
66
|
throw new Error('Google Maps is required for pi.Map');
|
|
39
67
|
}
|
|
40
68
|
|
|
41
69
|
let center = Obj.only(options, ['lat', 'lng']);
|
|
42
70
|
|
|
43
|
-
if ( !
|
|
44
|
-
options.styles =
|
|
71
|
+
if ( !Obj.has(options, 'styles') ) {
|
|
72
|
+
options.styles = PicoMap.mapStyle;
|
|
45
73
|
}
|
|
46
74
|
|
|
47
75
|
options = Obj.assign({ gestureHandling: 'cooperative', scrollwheel: null, zoom: 12, center },
|
|
@@ -55,12 +83,12 @@ export class PicoMap
|
|
|
55
83
|
*
|
|
56
84
|
* @example Map.setMapStyle(style)
|
|
57
85
|
*
|
|
58
|
-
* @param {
|
|
86
|
+
* @param {any[]} [style] Style array
|
|
59
87
|
* @returns {PicoMap} Current class
|
|
60
88
|
*/
|
|
61
|
-
static setMapStyle(style = [])
|
|
89
|
+
static setMapStyle(style : any[] = []) : typeof PicoMap
|
|
62
90
|
{
|
|
63
|
-
|
|
91
|
+
PicoMap.mapStyle = style;
|
|
64
92
|
|
|
65
93
|
return this;
|
|
66
94
|
}
|
|
@@ -73,27 +101,27 @@ export class PicoMap
|
|
|
73
101
|
* @param {string} key Style key
|
|
74
102
|
* @param {any} [style] Style options
|
|
75
103
|
* @param {any} [extra] Extra options
|
|
76
|
-
* @returns {PicoMap} Current class
|
|
104
|
+
* @returns {typeof PicoMap} Current class
|
|
77
105
|
*/
|
|
78
|
-
static setMarkerStyle(key, style = {}, extra = {})
|
|
106
|
+
static setMarkerStyle(key : string, style : any = {}, extra : any = {}) : typeof PicoMap
|
|
79
107
|
{
|
|
80
|
-
if ( !
|
|
108
|
+
if ( !globalThis.google ) {
|
|
81
109
|
throw new Error('Google Maps is required for pi.Map');
|
|
82
110
|
}
|
|
83
111
|
|
|
84
|
-
if ( !
|
|
85
|
-
|
|
112
|
+
if ( !Obj.has(style, 'default') ) {
|
|
113
|
+
throw new Error('Marker style requires default property');
|
|
86
114
|
}
|
|
87
115
|
|
|
88
|
-
if ( !
|
|
116
|
+
if ( !Obj.has(style, 'width') ) {
|
|
89
117
|
style.width = 45;
|
|
90
118
|
}
|
|
91
119
|
|
|
92
|
-
if ( !
|
|
120
|
+
if ( !Obj.has(style, 'height') ) {
|
|
93
121
|
style.height = 45;
|
|
94
122
|
}
|
|
95
123
|
|
|
96
|
-
let final = {};
|
|
124
|
+
let final : any = {};
|
|
97
125
|
|
|
98
126
|
// Marker size
|
|
99
127
|
let size = new globalThis.google.maps.Size(style.width, style.height);
|
|
@@ -112,7 +140,7 @@ export class PicoMap
|
|
|
112
140
|
final.hover = Obj.assign({}, final.default, { url: style.hover });
|
|
113
141
|
}
|
|
114
142
|
|
|
115
|
-
if ( !
|
|
143
|
+
if ( !Obj.has(final, 'hover') ) {
|
|
116
144
|
final.hover = final.default;
|
|
117
145
|
}
|
|
118
146
|
|
|
@@ -120,7 +148,7 @@ export class PicoMap
|
|
|
120
148
|
final.active = Obj.assign({}, final.default, { url: style.active });
|
|
121
149
|
}
|
|
122
150
|
|
|
123
|
-
if ( !
|
|
151
|
+
if ( !Obj.has(final, 'active') ) {
|
|
124
152
|
final.active = final.default;
|
|
125
153
|
}
|
|
126
154
|
|
|
@@ -128,7 +156,7 @@ export class PicoMap
|
|
|
128
156
|
final[prop] = Obj.assign({}, final.default, { url: value });
|
|
129
157
|
});
|
|
130
158
|
|
|
131
|
-
Obj.set(
|
|
159
|
+
Obj.set(PicoMap.markerStyles, key, final);
|
|
132
160
|
|
|
133
161
|
return this;
|
|
134
162
|
}
|
|
@@ -143,9 +171,9 @@ export class PicoMap
|
|
|
143
171
|
* @param {boolean} [allowCreate] Create cluster
|
|
144
172
|
* @returns {void} No return value
|
|
145
173
|
*/
|
|
146
|
-
clusterMarkers(options = {}, filter = null, allowCreate = true)
|
|
174
|
+
clusterMarkers(options : any = {}, filter : any = null, allowCreate : boolean = true) : void
|
|
147
175
|
{
|
|
148
|
-
if ( !
|
|
176
|
+
if ( !this.cluster && !allowCreate ) {
|
|
149
177
|
return;
|
|
150
178
|
}
|
|
151
179
|
|
|
@@ -153,7 +181,7 @@ export class PicoMap
|
|
|
153
181
|
return console.error('Google Maps Cluster library not laoded!');
|
|
154
182
|
}
|
|
155
183
|
|
|
156
|
-
if ( !
|
|
184
|
+
if ( !Obj.has(options, 'imagePath') && !Obj.has(options, 'styles') ) {
|
|
157
185
|
options.imagePath = '//developers.google.com/maps/documentation/javascript/examples/markerclusterer/m';
|
|
158
186
|
}
|
|
159
187
|
|
|
@@ -169,7 +197,7 @@ export class PicoMap
|
|
|
169
197
|
|
|
170
198
|
let visible = this.getMarkerVisibility(item.key);
|
|
171
199
|
|
|
172
|
-
if ( !
|
|
200
|
+
if ( !Mix.isFunction(this.clusterFilter) ) {
|
|
173
201
|
return visible;
|
|
174
202
|
}
|
|
175
203
|
|
|
@@ -189,7 +217,7 @@ export class PicoMap
|
|
|
189
217
|
* @param {any} [type] Style type
|
|
190
218
|
* @returns {void} No return value
|
|
191
219
|
*/
|
|
192
|
-
styleMarker(key, type = null)
|
|
220
|
+
styleMarker(key : string, type : any = null) : void
|
|
193
221
|
{
|
|
194
222
|
let item = Obj.get(this.markers, key);
|
|
195
223
|
|
|
@@ -201,11 +229,11 @@ export class PicoMap
|
|
|
201
229
|
type = this.getInfoVisibility(key) ? 'active' : 'default';
|
|
202
230
|
}
|
|
203
231
|
|
|
204
|
-
if ( !
|
|
232
|
+
if ( !Obj.has(PicoMap.markerStyles, [item.style, type]) ) {
|
|
205
233
|
return;
|
|
206
234
|
}
|
|
207
235
|
|
|
208
|
-
item.marker.setIcon(Obj.get(
|
|
236
|
+
item.marker.setIcon(Obj.get(PicoMap.markerStyles, [item.style, type]));
|
|
209
237
|
}
|
|
210
238
|
|
|
211
239
|
/**
|
|
@@ -216,7 +244,7 @@ export class PicoMap
|
|
|
216
244
|
* @param {string} key Marker key
|
|
217
245
|
* @returns {any} Marker object
|
|
218
246
|
*/
|
|
219
|
-
getMarker(key)
|
|
247
|
+
getMarker(key : string) : any
|
|
220
248
|
{
|
|
221
249
|
return Obj.get(this.markers, key);
|
|
222
250
|
}
|
|
@@ -230,7 +258,7 @@ export class PicoMap
|
|
|
230
258
|
* @param {boolean} [fallback] Fallback value
|
|
231
259
|
* @returns {boolean} Visibility state
|
|
232
260
|
*/
|
|
233
|
-
getMarkerVisibility(key, fallback = false)
|
|
261
|
+
getMarkerVisibility(key : string, fallback : boolean = false) : boolean
|
|
234
262
|
{
|
|
235
263
|
let item = Obj.get(this.markers, key);
|
|
236
264
|
|
|
@@ -250,7 +278,7 @@ export class PicoMap
|
|
|
250
278
|
* @param {any} [fallback] Fallback value
|
|
251
279
|
* @returns {any} Position object
|
|
252
280
|
*/
|
|
253
|
-
getMarkerPositon(key, fallback = null)
|
|
281
|
+
getMarkerPositon(key : string, fallback : any = null) : any
|
|
254
282
|
{
|
|
255
283
|
let item = Obj.get(this.markers, key);
|
|
256
284
|
|
|
@@ -267,14 +295,14 @@ export class PicoMap
|
|
|
267
295
|
* @example map.toggleMarker("m1")
|
|
268
296
|
*
|
|
269
297
|
* @param {string} key Marker key
|
|
270
|
-
* @returns {boolean
|
|
298
|
+
* @returns {boolean} Visibility state
|
|
271
299
|
*/
|
|
272
|
-
toggleMarker(key)
|
|
300
|
+
toggleMarker(key : string) : boolean
|
|
273
301
|
{
|
|
274
302
|
let item = Obj.get(this.markers, key);
|
|
275
303
|
|
|
276
304
|
if ( Mix.isEmpty(item) ) {
|
|
277
|
-
|
|
305
|
+
throw new Error(`Marker "${key}" not found`);
|
|
278
306
|
}
|
|
279
307
|
|
|
280
308
|
if ( item.marker.getVisible() ) {
|
|
@@ -290,17 +318,17 @@ export class PicoMap
|
|
|
290
318
|
* @example map.showMarker("m1")
|
|
291
319
|
*
|
|
292
320
|
* @param {string} key Marker key
|
|
293
|
-
* @returns {boolean
|
|
321
|
+
* @returns {boolean} Previous state
|
|
294
322
|
*/
|
|
295
|
-
showMarker(key)
|
|
323
|
+
showMarker(key : string) : boolean
|
|
296
324
|
{
|
|
297
325
|
let item = Obj.get(this.markers, key);
|
|
298
326
|
|
|
299
327
|
if ( Mix.isEmpty(item) ) {
|
|
300
|
-
|
|
328
|
+
throw new Error(`Marker "${key}" not found`);
|
|
301
329
|
}
|
|
302
330
|
|
|
303
|
-
let hidden = !
|
|
331
|
+
let hidden = !item.marker.getVisible();
|
|
304
332
|
|
|
305
333
|
if ( hidden ) {
|
|
306
334
|
item.marker.setVisible(true);
|
|
@@ -315,17 +343,17 @@ export class PicoMap
|
|
|
315
343
|
* @example map.hideMarker("m1")
|
|
316
344
|
*
|
|
317
345
|
* @param {string} key Marker key
|
|
318
|
-
* @returns {boolean
|
|
346
|
+
* @returns {boolean} Previous state
|
|
319
347
|
*/
|
|
320
|
-
hideMarker(key)
|
|
348
|
+
hideMarker(key : string) : boolean
|
|
321
349
|
{
|
|
322
350
|
let item = Obj.get(this.markers, key);
|
|
323
351
|
|
|
324
352
|
if ( Mix.isEmpty(item) ) {
|
|
325
|
-
|
|
353
|
+
throw new Error(`Marker "${key}" not found`);
|
|
326
354
|
}
|
|
327
355
|
|
|
328
|
-
let visible = !!
|
|
356
|
+
let visible = !!item.marker.getVisible();
|
|
329
357
|
|
|
330
358
|
if ( visible ) {
|
|
331
359
|
item.marker.setVisible(false);
|
|
@@ -342,14 +370,14 @@ export class PicoMap
|
|
|
342
370
|
* @example map.enterMarker("m1")
|
|
343
371
|
*
|
|
344
372
|
* @param {string} key Marker key
|
|
345
|
-
* @returns {
|
|
373
|
+
* @returns {PicoMap} Current instance
|
|
346
374
|
*/
|
|
347
|
-
enterMarker(key)
|
|
375
|
+
enterMarker(key : string) : PicoMap
|
|
348
376
|
{
|
|
349
377
|
let item = Obj.get(this.markers, key);
|
|
350
378
|
|
|
351
379
|
if ( Mix.isEmpty(item) ) {
|
|
352
|
-
|
|
380
|
+
throw new Error(`Marker "${key}" not found`);
|
|
353
381
|
}
|
|
354
382
|
|
|
355
383
|
let type = 'hover';
|
|
@@ -369,14 +397,14 @@ export class PicoMap
|
|
|
369
397
|
* @example map.leaveMarker("m1")
|
|
370
398
|
*
|
|
371
399
|
* @param {string} key Marker key
|
|
372
|
-
* @returns {
|
|
400
|
+
* @returns {PicoMap} Current instance
|
|
373
401
|
*/
|
|
374
|
-
leaveMarker(key)
|
|
402
|
+
leaveMarker(key : string) : PicoMap
|
|
375
403
|
{
|
|
376
404
|
let item = Obj.get(this.markers, key);
|
|
377
405
|
|
|
378
406
|
if ( Mix.isEmpty(item) ) {
|
|
379
|
-
|
|
407
|
+
throw new Error(`Marker "${key}" not found`);
|
|
380
408
|
}
|
|
381
409
|
|
|
382
410
|
let type = 'default';
|
|
@@ -399,15 +427,15 @@ export class PicoMap
|
|
|
399
427
|
* @param {boolean} [fallback] Fallback value
|
|
400
428
|
* @returns {boolean} Visibility state
|
|
401
429
|
*/
|
|
402
|
-
getInfoVisibility(key, fallback = false)
|
|
430
|
+
getInfoVisibility(key : string, fallback : boolean = false) : boolean
|
|
403
431
|
{
|
|
404
432
|
let item = Obj.get(this.markers, key);
|
|
405
433
|
|
|
406
|
-
if ( Mix.isEmpty(item) || !
|
|
434
|
+
if ( Mix.isEmpty(item) || !Obj.has(item, 'info') ) {
|
|
407
435
|
return fallback;
|
|
408
436
|
}
|
|
409
437
|
|
|
410
|
-
return !!
|
|
438
|
+
return !!item.info.getMap();
|
|
411
439
|
}
|
|
412
440
|
|
|
413
441
|
/**
|
|
@@ -416,14 +444,14 @@ export class PicoMap
|
|
|
416
444
|
* @example map.toggleInfo("m1")
|
|
417
445
|
*
|
|
418
446
|
* @param {string} key Marker key
|
|
419
|
-
* @returns {boolean
|
|
447
|
+
* @returns {boolean} Visibility state
|
|
420
448
|
*/
|
|
421
|
-
toggleInfo(key)
|
|
449
|
+
toggleInfo(key : string) : boolean
|
|
422
450
|
{
|
|
423
451
|
let item = Obj.get(this.markers, key);
|
|
424
452
|
|
|
425
453
|
if ( Mix.isEmpty(item) ) {
|
|
426
|
-
|
|
454
|
+
throw new Error(`Marker "${key}" not found`);
|
|
427
455
|
}
|
|
428
456
|
|
|
429
457
|
if ( item.info.getMap() ) {
|
|
@@ -439,23 +467,23 @@ export class PicoMap
|
|
|
439
467
|
* @example map.openInfo("m1")
|
|
440
468
|
*
|
|
441
469
|
* @param {string} key Marker key
|
|
442
|
-
* @returns {boolean
|
|
470
|
+
* @returns {boolean} Previous state
|
|
443
471
|
*/
|
|
444
|
-
openInfo(key)
|
|
472
|
+
openInfo(key : string) : boolean
|
|
445
473
|
{
|
|
446
474
|
let item = Obj.get(this.markers, key);
|
|
447
475
|
|
|
448
476
|
if ( Mix.isEmpty(item) ) {
|
|
449
|
-
|
|
477
|
+
throw new Error(`InfoWindow "${key}" not found`);
|
|
450
478
|
}
|
|
451
479
|
|
|
452
|
-
if ( !
|
|
480
|
+
if ( !Obj.has(item, 'info') ) {
|
|
453
481
|
return true;
|
|
454
482
|
}
|
|
455
483
|
|
|
456
|
-
let hidden = !
|
|
484
|
+
let hidden = !item.info.getMap();
|
|
457
485
|
|
|
458
|
-
if (
|
|
486
|
+
if ( PicoMap.closeInfoWindows ) {
|
|
459
487
|
Obj.each(Mix.keys(this.markers), this.closeInfo.bind(this));
|
|
460
488
|
}
|
|
461
489
|
|
|
@@ -478,21 +506,21 @@ export class PicoMap
|
|
|
478
506
|
* @example map.closeInfo("m1")
|
|
479
507
|
*
|
|
480
508
|
* @param {string} key Marker key
|
|
481
|
-
* @returns {boolean
|
|
509
|
+
* @returns {boolean} Previous state
|
|
482
510
|
*/
|
|
483
|
-
closeInfo(key)
|
|
511
|
+
closeInfo(key : string) : boolean
|
|
484
512
|
{
|
|
485
513
|
let item = Obj.get(this.markers, key);
|
|
486
514
|
|
|
487
515
|
if ( Mix.isEmpty(item) ) {
|
|
488
|
-
|
|
516
|
+
throw new Error(`InfoWindow "${key}" not found`);
|
|
489
517
|
}
|
|
490
518
|
|
|
491
|
-
if ( !
|
|
519
|
+
if ( !Obj.has(item, 'info') ) {
|
|
492
520
|
return false;
|
|
493
521
|
}
|
|
494
522
|
|
|
495
|
-
let visible = !!
|
|
523
|
+
let visible = !!item.info.getMap();
|
|
496
524
|
|
|
497
525
|
if ( visible ) {
|
|
498
526
|
item.info.close();
|
|
@@ -516,15 +544,15 @@ export class PicoMap
|
|
|
516
544
|
* @param {any} [options] Marker options
|
|
517
545
|
* @returns {any} Marker object
|
|
518
546
|
*/
|
|
519
|
-
createMarker(key = null, options = {})
|
|
547
|
+
createMarker(key : any = null, options : any = {}) : any
|
|
520
548
|
{
|
|
521
549
|
if ( Mix.isEmpty(key) ) {
|
|
522
550
|
key = Hash.uuid();
|
|
523
551
|
}
|
|
524
552
|
|
|
525
|
-
let item = { key };
|
|
553
|
+
let item : any = { key };
|
|
526
554
|
|
|
527
|
-
if ( !
|
|
555
|
+
if ( !Obj.has(options, 'visible') ) {
|
|
528
556
|
options.visible = true;
|
|
529
557
|
}
|
|
530
558
|
|
|
@@ -532,11 +560,11 @@ export class PicoMap
|
|
|
532
560
|
'map', 'position', 'lat', 'lng', 'html', 'style', 'visible', 'onOpen', 'onClose'
|
|
533
561
|
]);
|
|
534
562
|
|
|
535
|
-
if ( !
|
|
563
|
+
if ( !Obj.has(options, 'map') ) {
|
|
536
564
|
options.map = this.map;
|
|
537
565
|
}
|
|
538
566
|
|
|
539
|
-
if ( !
|
|
567
|
+
if ( !Obj.has(options, 'position') ) {
|
|
540
568
|
options.position = Obj.only(options, ['lat', 'lng']);
|
|
541
569
|
}
|
|
542
570
|
|
|
@@ -558,11 +586,11 @@ export class PicoMap
|
|
|
558
586
|
|
|
559
587
|
this.clusterMarkers(this.clusterOptions, null, false);
|
|
560
588
|
|
|
561
|
-
if ( !
|
|
589
|
+
if ( !Obj.has(options, 'html') ) {
|
|
562
590
|
return Obj.get(this.markers, key);
|
|
563
591
|
}
|
|
564
592
|
|
|
565
|
-
if ( !
|
|
593
|
+
if ( !Obj.has(item, 'style') ) {
|
|
566
594
|
item.style = 'default';
|
|
567
595
|
}
|
|
568
596
|
|
|
@@ -583,7 +611,7 @@ export class PicoMap
|
|
|
583
611
|
item.info.addListener('closeclick', () => this.closeInfo(key));
|
|
584
612
|
|
|
585
613
|
// Dom change event
|
|
586
|
-
item.info.addListener('domready', () =>
|
|
614
|
+
item.info.addListener('domready', () => Signal.fire('MapsDomReady'));
|
|
587
615
|
|
|
588
616
|
Obj.set(this.markers, key, item);
|
|
589
617
|
|
|
@@ -599,7 +627,7 @@ export class PicoMap
|
|
|
599
627
|
* @param {any} [options] Position options
|
|
600
628
|
* @returns {void} No return value
|
|
601
629
|
*/
|
|
602
|
-
setMarkerPosition(key, options = {})
|
|
630
|
+
setMarkerPosition(key : string, options : any = {}) : void
|
|
603
631
|
{
|
|
604
632
|
let item = Obj.get(this.markers, key);
|
|
605
633
|
|
|
@@ -619,9 +647,9 @@ export class PicoMap
|
|
|
619
647
|
* @param {any} address Search address
|
|
620
648
|
* @returns {Promise<any>} Response promise
|
|
621
649
|
*/
|
|
622
|
-
setMarkerByAddress(key, address)
|
|
650
|
+
setMarkerByAddress(key : string, address : any) : Promise<any>
|
|
623
651
|
{
|
|
624
|
-
return this.getLocationByAddress(address, (res) => {
|
|
652
|
+
return this.getLocationByAddress(address, (res : any) => {
|
|
625
653
|
this.setMarkerPosition(key, Obj.get(res, '0.geometry.location', {}));
|
|
626
654
|
});
|
|
627
655
|
}
|
|
@@ -632,16 +660,16 @@ export class PicoMap
|
|
|
632
660
|
* @example map.getLocationByAddress("Address")
|
|
633
661
|
*
|
|
634
662
|
* @param {any} address Search address
|
|
635
|
-
* @param {
|
|
663
|
+
* @param {Function} [callback] Success callback
|
|
636
664
|
* @returns {Promise<any>} Response promise
|
|
637
665
|
*/
|
|
638
|
-
getLocationByAddress(address, callback = null)
|
|
666
|
+
getLocationByAddress(address : any, callback : Function = null) : Promise<any>
|
|
639
667
|
{
|
|
640
668
|
let geocoderService = new globalThis.google.maps.Geocoder();
|
|
641
669
|
|
|
642
|
-
let geocoderPromise = (resolve, reject) => {
|
|
670
|
+
let geocoderPromise = (resolve : any, reject : any) => {
|
|
643
671
|
|
|
644
|
-
let geocoderResult = (response, status) => {
|
|
672
|
+
let geocoderResult = (response : any, status : any) => {
|
|
645
673
|
|
|
646
674
|
if ( status === 'OK' ) {
|
|
647
675
|
callback(response);
|
|
@@ -668,19 +696,21 @@ export class PicoMap
|
|
|
668
696
|
* @param {any} [filter] Marker filter
|
|
669
697
|
* @returns {PicoMap} Current instance
|
|
670
698
|
*/
|
|
671
|
-
showMarkers(filter = null)
|
|
699
|
+
showMarkers(filter : any = null) : PicoMap
|
|
672
700
|
{
|
|
673
701
|
let markers = this.markers;
|
|
674
702
|
|
|
675
|
-
if ( !
|
|
703
|
+
if ( !Mix.isEmpty(filter) ) {
|
|
676
704
|
markers = Obj.filter(this.markers, filter);
|
|
677
705
|
}
|
|
678
706
|
|
|
679
|
-
if (
|
|
707
|
+
if ( PicoMap.hideMarkers ) {
|
|
680
708
|
Obj.each(Mix.keys(this.markers), this.hideMarker.bind(this));
|
|
681
709
|
}
|
|
682
710
|
|
|
683
|
-
Obj.each(markers, (item) =>
|
|
711
|
+
Obj.each(markers, (item : any) => {
|
|
712
|
+
return this.showMarker(item.key);
|
|
713
|
+
});
|
|
684
714
|
|
|
685
715
|
this.clusterMarkers(this.clusterOptions, null, false);
|
|
686
716
|
|
|
@@ -695,17 +725,17 @@ export class PicoMap
|
|
|
695
725
|
* @param {any} [filter] Marker filter
|
|
696
726
|
* @returns {any} Boundary object
|
|
697
727
|
*/
|
|
698
|
-
getMarkerBoundry(filter = null)
|
|
728
|
+
getMarkerBoundry(filter : any = null) : any
|
|
699
729
|
{
|
|
700
730
|
let markers = this.markers;
|
|
701
731
|
|
|
702
|
-
if ( !
|
|
732
|
+
if ( !Mix.isEmpty(filter) ) {
|
|
703
733
|
markers = Obj.filter(this.markers, filter);
|
|
704
734
|
}
|
|
705
735
|
|
|
706
736
|
let boundry = new globalThis.google.maps.LatLngBounds();
|
|
707
737
|
|
|
708
|
-
Obj.each(markers, (item) => {
|
|
738
|
+
Obj.each(markers, (item : any) => {
|
|
709
739
|
if ( item.marker.getVisible() ) {
|
|
710
740
|
boundry.extend(item.marker.getPosition());
|
|
711
741
|
}
|
|
@@ -724,7 +754,7 @@ export class PicoMap
|
|
|
724
754
|
* @param {number} [boundSpace] Viewport space
|
|
725
755
|
* @returns {PicoMap} Current instance
|
|
726
756
|
*/
|
|
727
|
-
focusMarkers(filter = null, maxZoom = 14, boundSpace = 15)
|
|
757
|
+
focusMarkers(filter : any = null, maxZoom : number = 14, boundSpace : number = 15) : PicoMap
|
|
728
758
|
{
|
|
729
759
|
let boundry = this.getMarkerBoundry(filter);
|
|
730
760
|
|
|
@@ -749,7 +779,7 @@ export class PicoMap
|
|
|
749
779
|
* @param {any} options Render options
|
|
750
780
|
* @returns {Promise<any>} Response promise
|
|
751
781
|
*/
|
|
752
|
-
renderDirections(options)
|
|
782
|
+
renderDirections(options : any) : Promise<any>
|
|
753
783
|
{
|
|
754
784
|
// Get directions service
|
|
755
785
|
let directionsService = new globalThis.google.maps.DirectionsService();
|
|
@@ -757,26 +787,26 @@ export class PicoMap
|
|
|
757
787
|
// Get directions renderer
|
|
758
788
|
let directionsRenderer = new globalThis.google.maps.DirectionsRenderer();
|
|
759
789
|
|
|
760
|
-
if ( !
|
|
790
|
+
if ( !Obj.has(options, 'map') ) {
|
|
761
791
|
options.map = this.map;
|
|
762
792
|
}
|
|
763
793
|
|
|
764
|
-
if ( !
|
|
794
|
+
if ( !Obj.has(options, 'travelMode') ) {
|
|
765
795
|
options.travelMode = 'DRIVING';
|
|
766
796
|
}
|
|
767
797
|
|
|
768
798
|
// Set directions map
|
|
769
799
|
directionsRenderer.setMap(options.map);
|
|
770
800
|
|
|
771
|
-
if ( Obj.has(options, 'panel') && !
|
|
801
|
+
if ( Obj.has(options, 'panel') && !Dom.find(options.panel).empty() ) {
|
|
772
802
|
directionsRenderer.setPanel(Dom.find(options.panel).get(0));
|
|
773
803
|
}
|
|
774
804
|
|
|
775
805
|
options = Obj.only(options, ['origin', 'destination', 'travelMode']);
|
|
776
806
|
|
|
777
|
-
let directionsPromise = (resolve, reject) => {
|
|
807
|
+
let directionsPromise = (resolve : any, reject : any) => {
|
|
778
808
|
|
|
779
|
-
let directionsResult = (response, status) => {
|
|
809
|
+
let directionsResult = (response : any, status : any) => {
|
|
780
810
|
|
|
781
811
|
if ( status === 'OK' ) {
|
|
782
812
|
directionsRenderer.setDirections(response);
|