neo.mjs 4.4.11 → 4.4.13
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.
@@ -21,11 +21,19 @@ class MainContainer extends Viewport {
|
|
21
21
|
flex : 1,
|
22
22
|
reference: 'google-maps-component',
|
23
23
|
|
24
|
+
listeners: {
|
25
|
+
zoomChange: 'onMapZoomChance'
|
26
|
+
},
|
27
|
+
|
24
28
|
markerStoreConfig: {
|
25
29
|
data: [{
|
26
30
|
id : '1',
|
27
|
-
position: {lat: -
|
31
|
+
position: {lat: -33.397, lng: 150.644},
|
28
32
|
title : 'Hello neo'
|
33
|
+
}, {
|
34
|
+
id : '2',
|
35
|
+
position: {lat: -34.397, lng: 150.644},
|
36
|
+
title : 'Hello Max'
|
29
37
|
}]
|
30
38
|
}
|
31
39
|
}, {
|
@@ -46,6 +54,7 @@ class MainContainer extends Viewport {
|
|
46
54
|
listeners : {change: 'onZoomFieldChange'},
|
47
55
|
minValue : 0,
|
48
56
|
maxValue : 10,
|
57
|
+
reference : 'zoom-field',
|
49
58
|
style : {marginLeft: '10px'},
|
50
59
|
value : 8,
|
51
60
|
width : 100
|
@@ -56,7 +65,7 @@ class MainContainer extends Viewport {
|
|
56
65
|
iconCls: 'fa-solid fa-trash',
|
57
66
|
mode : 'hide',
|
58
67
|
style : {marginLeft: '10px'},
|
59
|
-
text : 'Hide marker'
|
68
|
+
text : 'Hide marker 1'
|
60
69
|
}]
|
61
70
|
}]
|
62
71
|
}}
|
@@ -20,6 +20,13 @@ class MainContainerController extends ComponentController {
|
|
20
20
|
this.getReference('google-maps-component').panTo({lat: 37.655, lng: -122.4175})
|
21
21
|
}
|
22
22
|
|
23
|
+
/**
|
24
|
+
* @param {Object} data
|
25
|
+
*/
|
26
|
+
onMapZoomChance(data) {
|
27
|
+
this.getReference('zoom-field').value = data.value;
|
28
|
+
}
|
29
|
+
|
23
30
|
/**
|
24
31
|
* @param {Object} data
|
25
32
|
*/
|
@@ -31,7 +38,7 @@ class MainContainerController extends ComponentController {
|
|
31
38
|
button.set({
|
32
39
|
iconCls: 'fa fa-location-dot',
|
33
40
|
mode : 'show',
|
34
|
-
text : 'Show marker'
|
41
|
+
text : 'Show marker 1'
|
35
42
|
});
|
36
43
|
|
37
44
|
map.hideMarker('1')
|
@@ -39,7 +46,7 @@ class MainContainerController extends ComponentController {
|
|
39
46
|
button.set({
|
40
47
|
iconCls: 'fa-solid fa-trash',
|
41
48
|
mode : 'hide',
|
42
|
-
text : 'Hide marker'
|
49
|
+
text : 'Hide marker 1'
|
43
50
|
});
|
44
51
|
|
45
52
|
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,28 @@ 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
|
+
googleMapZoomChange: me.onMapZoomChange,
|
86
|
+
googleMarkerClick : me.parseMarkerClick,
|
87
|
+
local : false,
|
88
|
+
scope : me
|
89
|
+
})
|
90
|
+
}
|
91
|
+
|
70
92
|
/**
|
71
93
|
* @param {Object} data
|
72
94
|
* @param {String} data.id
|
@@ -137,6 +159,7 @@ class GoogleMaps extends Base {
|
|
137
159
|
center : me.center,
|
138
160
|
fullscreenControl: me.fullscreenControl,
|
139
161
|
id : me.id,
|
162
|
+
mapOptions : me.mapOptions,
|
140
163
|
maxZoom : me.maxZoom,
|
141
164
|
minZoom : me.minZoom,
|
142
165
|
zoom : me.zoom,
|
@@ -159,9 +182,16 @@ class GoogleMaps extends Base {
|
|
159
182
|
*/
|
160
183
|
afterSetZoom(value, oldValue) {
|
161
184
|
if (oldValue !== undefined) {
|
185
|
+
let me = this;
|
186
|
+
|
162
187
|
Neo.main.addon.GoogleMaps.setZoom({
|
163
|
-
appName:
|
164
|
-
id :
|
188
|
+
appName: me.appName,
|
189
|
+
id : me.id,
|
190
|
+
value
|
191
|
+
});
|
192
|
+
|
193
|
+
me.fire('zoomChange', {
|
194
|
+
id: me.id,
|
165
195
|
value
|
166
196
|
})
|
167
197
|
}
|
@@ -204,6 +234,20 @@ class GoogleMaps extends Base {
|
|
204
234
|
*/
|
205
235
|
onComponentMounted() {}
|
206
236
|
|
237
|
+
/**
|
238
|
+
* @param {Object} data
|
239
|
+
*/
|
240
|
+
onMapZoomChange(data) {
|
241
|
+
this.zoom = data.value;
|
242
|
+
}
|
243
|
+
|
244
|
+
/**
|
245
|
+
* @param {Object} record
|
246
|
+
*/
|
247
|
+
onMarkerClick(record) {
|
248
|
+
console.log('onMarkerClick', record);
|
249
|
+
}
|
250
|
+
|
207
251
|
/**
|
208
252
|
*
|
209
253
|
*/
|
@@ -232,6 +276,23 @@ class GoogleMaps extends Base {
|
|
232
276
|
})
|
233
277
|
}
|
234
278
|
|
279
|
+
/**
|
280
|
+
* Internal function. Use onMarkerClick() or the markerClick event instead
|
281
|
+
* @param {Object} data
|
282
|
+
* @protected
|
283
|
+
*/
|
284
|
+
parseMarkerClick(data) {
|
285
|
+
let me = this,
|
286
|
+
record = me.markerStore.get(data.id);
|
287
|
+
|
288
|
+
me.onMarkerClick(record);
|
289
|
+
|
290
|
+
me.fire('markerClick', {
|
291
|
+
id: me.id,
|
292
|
+
record
|
293
|
+
})
|
294
|
+
}
|
295
|
+
|
235
296
|
/**
|
236
297
|
*
|
237
298
|
*/
|
@@ -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,23 +68,29 @@ class GoogleMaps extends Base {
|
|
66
68
|
* @param {String} [data.title]
|
67
69
|
*/
|
68
70
|
addMarker(data) {
|
69
|
-
let me
|
71
|
+
let me = this,
|
72
|
+
mapId = data.mapId,
|
73
|
+
listenerId, marker;
|
70
74
|
|
71
|
-
if (!me.maps[
|
72
|
-
|
73
|
-
if (
|
75
|
+
if (!me.maps[mapId]) {
|
76
|
+
listenerId = me.on('mapCreated', id => {
|
77
|
+
if (mapId === id) {
|
74
78
|
me.un(listenerId);
|
75
79
|
me.addMarker(data);
|
76
80
|
}
|
77
81
|
})
|
78
82
|
} else {
|
79
|
-
Neo.ns(`${
|
83
|
+
Neo.ns(`${mapId}`, true, me.markers);
|
80
84
|
|
81
|
-
me.markers[
|
85
|
+
me.markers[mapId][data.id] = marker = new google.maps.Marker({
|
86
|
+
map : me.maps[mapId],
|
87
|
+
neoId : data.id, // custom property
|
88
|
+
neoMapId: mapId, // custom property
|
82
89
|
position: data.position,
|
83
|
-
map : me.maps[data.mapId],
|
84
90
|
title : data.title,
|
85
91
|
});
|
92
|
+
|
93
|
+
marker.addListener('click', me.onMarkerClick.bind(me, marker));
|
86
94
|
}
|
87
95
|
}
|
88
96
|
|
@@ -91,24 +99,30 @@ class GoogleMaps extends Base {
|
|
91
99
|
* @param {Object} data.center
|
92
100
|
* @param {Boolean} data.fullscreenControl
|
93
101
|
* @param {String} data.id
|
102
|
+
* @param {Object} data.mapOptions // Pass any options which are not explicitly defined here
|
94
103
|
* @param {Number} data.maxZoom
|
95
104
|
* @param {Number} data.minZoom
|
96
105
|
* @param {Number} data.zoom
|
97
106
|
* @param {Boolean} data.zoomControl
|
98
107
|
*/
|
99
108
|
create(data) {
|
100
|
-
let me = this
|
109
|
+
let me = this,
|
110
|
+
id = data.id,
|
111
|
+
map;
|
101
112
|
|
102
|
-
me.maps[
|
113
|
+
me.maps[id] = map = new google.maps.Map(DomAccess.getElement(id), {
|
103
114
|
center : data.center,
|
104
115
|
fullscreenControl: data.fullscreenControl,
|
105
116
|
maxZoom : data.maxZoom,
|
106
117
|
minZoom : data.minZoom,
|
107
118
|
zoom : data.zoom,
|
108
|
-
zoomControl : data.zoomControl
|
119
|
+
zoomControl : data.zoomControl,
|
120
|
+
...data.mapOptions
|
109
121
|
});
|
110
122
|
|
111
|
-
|
123
|
+
map.addListener('zoom_changed', me.onMapZoomChange.bind(me, map, id));
|
124
|
+
|
125
|
+
me.fire('mapCreated', id);
|
112
126
|
}
|
113
127
|
|
114
128
|
/**
|
@@ -131,6 +145,35 @@ class GoogleMaps extends Base {
|
|
131
145
|
})
|
132
146
|
}
|
133
147
|
|
148
|
+
/**
|
149
|
+
* @param {google.maps.Map} map
|
150
|
+
* @param {String} mapId
|
151
|
+
*/
|
152
|
+
onMapZoomChange(map, mapId){
|
153
|
+
DomEvents.sendMessageToApp({
|
154
|
+
id : mapId,
|
155
|
+
path : [{cls: [], id: mapId}],
|
156
|
+
type : 'googleMapZoomChange',
|
157
|
+
value: map.zoom
|
158
|
+
})
|
159
|
+
}
|
160
|
+
|
161
|
+
/**
|
162
|
+
* @param {google.maps.Marker} marker
|
163
|
+
* @param {Object} event
|
164
|
+
* @param {Object} event.domEvent
|
165
|
+
*/
|
166
|
+
onMarkerClick(marker, event) {
|
167
|
+
// in theory, we could parse and pass the entire DOM event.
|
168
|
+
// feel free to open a feature request ticket, in case you need more data into the app worker.
|
169
|
+
|
170
|
+
DomEvents.sendMessageToApp({
|
171
|
+
id : marker.neoId,
|
172
|
+
path: [{cls: [], id: marker.neoMapId}],
|
173
|
+
type: 'googleMarkerClick'
|
174
|
+
})
|
175
|
+
}
|
176
|
+
|
134
177
|
/**
|
135
178
|
* @param data
|
136
179
|
* @param {String} data.mapId
|