neo.mjs 4.4.11 → 4.4.12
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.
@@ -24,8 +24,12 @@ class MainContainer extends Viewport {
|
|
24
24
|
markerStoreConfig: {
|
25
25
|
data: [{
|
26
26
|
id : '1',
|
27
|
-
position: {lat: -
|
27
|
+
position: {lat: -33.397, lng: 150.644},
|
28
28
|
title : 'Hello neo'
|
29
|
+
}, {
|
30
|
+
id : '2',
|
31
|
+
position: {lat: -34.397, lng: 150.644},
|
32
|
+
title : 'Hello Max'
|
29
33
|
}]
|
30
34
|
}
|
31
35
|
}, {
|
@@ -56,7 +60,7 @@ class MainContainer extends Viewport {
|
|
56
60
|
iconCls: 'fa-solid fa-trash',
|
57
61
|
mode : 'hide',
|
58
62
|
style : {marginLeft: '10px'},
|
59
|
-
text : 'Hide marker'
|
63
|
+
text : 'Hide marker 1'
|
60
64
|
}]
|
61
65
|
}]
|
62
66
|
}}
|
@@ -31,7 +31,7 @@ class MainContainerController extends ComponentController {
|
|
31
31
|
button.set({
|
32
32
|
iconCls: 'fa fa-location-dot',
|
33
33
|
mode : 'show',
|
34
|
-
text : 'Show marker'
|
34
|
+
text : 'Show marker 1'
|
35
35
|
});
|
36
36
|
|
37
37
|
map.hideMarker('1')
|
@@ -39,7 +39,7 @@ class MainContainerController extends ComponentController {
|
|
39
39
|
button.set({
|
40
40
|
iconCls: 'fa-solid fa-trash',
|
41
41
|
mode : 'hide',
|
42
|
-
text : 'Hide marker'
|
42
|
+
text : 'Hide marker 1'
|
43
43
|
});
|
44
44
|
|
45
45
|
map.showMarker('1')
|
package/package.json
CHANGED
@@ -7,6 +7,36 @@ import Store from '../../data/Store.mjs';
|
|
7
7
|
* @extends Neo.component.Base
|
8
8
|
*/
|
9
9
|
class GoogleMaps extends Base {
|
10
|
+
/**
|
11
|
+
* false hides the default fullscreen control
|
12
|
+
* @member {Boolean} fullscreenControl=true
|
13
|
+
*/
|
14
|
+
fullscreenControl = true
|
15
|
+
/**
|
16
|
+
* @member {Object} markerStoreConfig=null
|
17
|
+
*/
|
18
|
+
markerStoreConfig = null
|
19
|
+
/**
|
20
|
+
* Pass any options to the map instance which are not explicitly defined here
|
21
|
+
* @member {Object} mapOptions={}
|
22
|
+
*/
|
23
|
+
mapOptions = {}
|
24
|
+
/**
|
25
|
+
* null => the maximum zoom from the current map type is used instead
|
26
|
+
* @member {Number|null} maxZoom=null
|
27
|
+
*/
|
28
|
+
maxZoom = null
|
29
|
+
/**
|
30
|
+
null => the minimum zoom from the current map type is used instead
|
31
|
+
* @member {Number|null} minZoom=null
|
32
|
+
*/
|
33
|
+
minZoom = null
|
34
|
+
/**
|
35
|
+
* false hides the default zoom control
|
36
|
+
* @member {Boolean} zoomControl=true
|
37
|
+
*/
|
38
|
+
zoomControl = true
|
39
|
+
|
10
40
|
static getConfig() {return {
|
11
41
|
/**
|
12
42
|
* @member {String} className='Neo.component.wrapper.GoogleMaps'
|
@@ -18,11 +48,6 @@ class GoogleMaps extends Base {
|
|
18
48
|
* @member {Object} center_={lat: -34.397, lng: 150.644}
|
19
49
|
*/
|
20
50
|
center_: {lat: -34.397, lng: 150.644},
|
21
|
-
/**
|
22
|
-
* false hides the default fullscreen control
|
23
|
-
* @member {Boolean} fullscreenControl=true
|
24
|
-
*/
|
25
|
-
fullscreenControl: true,
|
26
51
|
/**
|
27
52
|
* Prefer to use markerStoreConfig instead.
|
28
53
|
* @member {Neo.data.Store|Object} markerStore_
|
@@ -42,31 +67,27 @@ class GoogleMaps extends Base {
|
|
42
67
|
}]
|
43
68
|
}
|
44
69
|
},
|
45
|
-
/**
|
46
|
-
* @member {Object} markerStoreConfig: null
|
47
|
-
*/
|
48
|
-
markerStoreConfig: null,
|
49
|
-
/**
|
50
|
-
* null => the maximum zoom from the current map type is used instead
|
51
|
-
* @member {Number|null} maxZoom=null
|
52
|
-
*/
|
53
|
-
maxZoom: null,
|
54
|
-
/**
|
55
|
-
null => the minimum zoom from the current map type is used instead
|
56
|
-
* @member {Number|null} minZoom=null
|
57
|
-
*/
|
58
|
-
minZoom: null,
|
59
70
|
/**
|
60
71
|
* @member {Number} zoom_=8
|
61
72
|
*/
|
62
|
-
zoom_: 8
|
63
|
-
/**
|
64
|
-
* false hides the default zoom control
|
65
|
-
* @member {Boolean} zoomControl=true
|
66
|
-
*/
|
67
|
-
zoomControl: true
|
73
|
+
zoom_: 8
|
68
74
|
}}
|
69
75
|
|
76
|
+
/**
|
77
|
+
* @param {Object} config
|
78
|
+
*/
|
79
|
+
construct(config) {
|
80
|
+
super.construct(config);
|
81
|
+
|
82
|
+
let me = this;
|
83
|
+
|
84
|
+
me.addDomListeners({
|
85
|
+
googleMarkerClick: me.parseMarkerClick,
|
86
|
+
local : false,
|
87
|
+
scope : me
|
88
|
+
})
|
89
|
+
}
|
90
|
+
|
70
91
|
/**
|
71
92
|
* @param {Object} data
|
72
93
|
* @param {String} data.id
|
@@ -137,6 +158,7 @@ class GoogleMaps extends Base {
|
|
137
158
|
center : me.center,
|
138
159
|
fullscreenControl: me.fullscreenControl,
|
139
160
|
id : me.id,
|
161
|
+
mapOptions : me.mapOptions,
|
140
162
|
maxZoom : me.maxZoom,
|
141
163
|
minZoom : me.minZoom,
|
142
164
|
zoom : me.zoom,
|
@@ -204,6 +226,13 @@ class GoogleMaps extends Base {
|
|
204
226
|
*/
|
205
227
|
onComponentMounted() {}
|
206
228
|
|
229
|
+
/**
|
230
|
+
* @param {Object} record
|
231
|
+
*/
|
232
|
+
onMarkerClick(record) {
|
233
|
+
console.log('onMarkerClick', record);
|
234
|
+
}
|
235
|
+
|
207
236
|
/**
|
208
237
|
*
|
209
238
|
*/
|
@@ -232,6 +261,23 @@ class GoogleMaps extends Base {
|
|
232
261
|
})
|
233
262
|
}
|
234
263
|
|
264
|
+
/**
|
265
|
+
* Internal function. Use onMarkerClick() or the markerClick event instead
|
266
|
+
* @param {Object} data
|
267
|
+
* @protected
|
268
|
+
*/
|
269
|
+
parseMarkerClick(data) {
|
270
|
+
let me = this,
|
271
|
+
record = me.markerStore.get(data.id);
|
272
|
+
|
273
|
+
me.onMarkerClick(record);
|
274
|
+
|
275
|
+
me.fire('markerClick', {
|
276
|
+
id: me.id,
|
277
|
+
record
|
278
|
+
})
|
279
|
+
}
|
280
|
+
|
235
281
|
/**
|
236
282
|
*
|
237
283
|
*/
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import Base from '../../core/Base.mjs';
|
2
2
|
import DomAccess from '../DomAccess.mjs';
|
3
|
+
import DomEvents from '../DomEvents.mjs';
|
3
4
|
import Observable from '../../core/Observable.mjs';
|
4
5
|
|
5
6
|
/**
|
@@ -8,20 +9,21 @@ import Observable from '../../core/Observable.mjs';
|
|
8
9
|
* @singleton
|
9
10
|
*/
|
10
11
|
class GoogleMaps extends Base {
|
12
|
+
/**
|
13
|
+
* @member {Object} maps={}
|
14
|
+
*/
|
15
|
+
maps = {}
|
16
|
+
/**
|
17
|
+
* @member {Object} markers={}
|
18
|
+
*/
|
19
|
+
markers = {}
|
20
|
+
|
11
21
|
static getConfig() {return {
|
12
22
|
/**
|
13
23
|
* @member {String} className='Neo.main.addon.GoogleMaps'
|
14
24
|
* @protected
|
15
25
|
*/
|
16
26
|
className: 'Neo.main.addon.GoogleMaps',
|
17
|
-
/**
|
18
|
-
* @member {Object} maps={}
|
19
|
-
*/
|
20
|
-
maps: {},
|
21
|
-
/**
|
22
|
-
* @member {Object} markers={}
|
23
|
-
*/
|
24
|
-
markers: {},
|
25
27
|
/**
|
26
28
|
* @member {Neo.core.Base[]} mixins=[Observable]
|
27
29
|
*/
|
@@ -66,10 +68,11 @@ class GoogleMaps extends Base {
|
|
66
68
|
* @param {String} [data.title]
|
67
69
|
*/
|
68
70
|
addMarker(data) {
|
69
|
-
let me = this
|
71
|
+
let me = this,
|
72
|
+
listenerId, marker;
|
70
73
|
|
71
74
|
if (!me.maps[data.mapId]) {
|
72
|
-
|
75
|
+
listenerId = me.on('mapCreated', mapId => {
|
73
76
|
if (data.mapId === mapId) {
|
74
77
|
me.un(listenerId);
|
75
78
|
me.addMarker(data);
|
@@ -78,11 +81,15 @@ class GoogleMaps extends Base {
|
|
78
81
|
} else {
|
79
82
|
Neo.ns(`${data.mapId}`, true, me.markers);
|
80
83
|
|
81
|
-
me.markers[data.mapId][data.id] = new google.maps.Marker({
|
82
|
-
position: data.position,
|
84
|
+
me.markers[data.mapId][data.id] = marker = new google.maps.Marker({
|
83
85
|
map : me.maps[data.mapId],
|
86
|
+
neoId : data.id, // custom property
|
87
|
+
neoMapId: data.mapId, // custom property
|
88
|
+
position: data.position,
|
84
89
|
title : data.title,
|
85
90
|
});
|
91
|
+
|
92
|
+
marker.addListener('click', me.onMarkerClick.bind(me, marker));
|
86
93
|
}
|
87
94
|
}
|
88
95
|
|
@@ -91,6 +98,7 @@ class GoogleMaps extends Base {
|
|
91
98
|
* @param {Object} data.center
|
92
99
|
* @param {Boolean} data.fullscreenControl
|
93
100
|
* @param {String} data.id
|
101
|
+
* @param {Object} data.mapOptions // Pass any options which are not explicitly defined here
|
94
102
|
* @param {Number} data.maxZoom
|
95
103
|
* @param {Number} data.minZoom
|
96
104
|
* @param {Number} data.zoom
|
@@ -105,7 +113,8 @@ class GoogleMaps extends Base {
|
|
105
113
|
maxZoom : data.maxZoom,
|
106
114
|
minZoom : data.minZoom,
|
107
115
|
zoom : data.zoom,
|
108
|
-
zoomControl : data.zoomControl
|
116
|
+
zoomControl : data.zoomControl,
|
117
|
+
...data.mapOptions
|
109
118
|
});
|
110
119
|
|
111
120
|
me.fire('mapCreated', data.id);
|
@@ -131,6 +140,22 @@ class GoogleMaps extends Base {
|
|
131
140
|
})
|
132
141
|
}
|
133
142
|
|
143
|
+
/**
|
144
|
+
* @param {google.maps.Marker} marker
|
145
|
+
* @param {Object} event
|
146
|
+
* @param {Object} event.domEvent
|
147
|
+
*/
|
148
|
+
onMarkerClick(marker, event) {
|
149
|
+
// in theory, we could parse and pass the entire DOM event.
|
150
|
+
// feel free to open a feature request ticket, in case you need more data into the app worker.
|
151
|
+
|
152
|
+
DomEvents.sendMessageToApp({
|
153
|
+
id : marker.neoId,
|
154
|
+
path: [{cls: [], id: marker.neoMapId}],
|
155
|
+
type: 'googleMarkerClick'
|
156
|
+
})
|
157
|
+
}
|
158
|
+
|
134
159
|
/**
|
135
160
|
* @param data
|
136
161
|
* @param {String} data.mapId
|