neo.mjs 4.4.12 → 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,6 +21,10 @@ 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',
@@ -50,6 +54,7 @@ class MainContainer extends Viewport {
50
54
  listeners : {change: 'onZoomFieldChange'},
51
55
  minValue : 0,
52
56
  maxValue : 10,
57
+ reference : 'zoom-field',
53
58
  style : {marginLeft: '10px'},
54
59
  value : 8,
55
60
  width : 100
@@ -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
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "neo.mjs",
3
- "version": "4.4.12",
3
+ "version": "4.4.13",
4
4
  "description": "The webworkers driven UI framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -82,9 +82,10 @@ class GoogleMaps extends Base {
82
82
  let me = this;
83
83
 
84
84
  me.addDomListeners({
85
- googleMarkerClick: me.parseMarkerClick,
86
- local : false,
87
- scope : me
85
+ googleMapZoomChange: me.onMapZoomChange,
86
+ googleMarkerClick : me.parseMarkerClick,
87
+ local : false,
88
+ scope : me
88
89
  })
89
90
  }
90
91
 
@@ -181,9 +182,16 @@ class GoogleMaps extends Base {
181
182
  */
182
183
  afterSetZoom(value, oldValue) {
183
184
  if (oldValue !== undefined) {
185
+ let me = this;
186
+
184
187
  Neo.main.addon.GoogleMaps.setZoom({
185
- appName: this.appName,
186
- id : this.id,
188
+ appName: me.appName,
189
+ id : me.id,
190
+ value
191
+ });
192
+
193
+ me.fire('zoomChange', {
194
+ id: me.id,
187
195
  value
188
196
  })
189
197
  }
@@ -226,6 +234,13 @@ class GoogleMaps extends Base {
226
234
  */
227
235
  onComponentMounted() {}
228
236
 
237
+ /**
238
+ * @param {Object} data
239
+ */
240
+ onMapZoomChange(data) {
241
+ this.zoom = data.value;
242
+ }
243
+
229
244
  /**
230
245
  * @param {Object} record
231
246
  */
@@ -68,23 +68,24 @@ class GoogleMaps extends Base {
68
68
  * @param {String} [data.title]
69
69
  */
70
70
  addMarker(data) {
71
- let me = this,
71
+ let me = this,
72
+ mapId = data.mapId,
72
73
  listenerId, marker;
73
74
 
74
- if (!me.maps[data.mapId]) {
75
- listenerId = me.on('mapCreated', mapId => {
76
- if (data.mapId === mapId) {
75
+ if (!me.maps[mapId]) {
76
+ listenerId = me.on('mapCreated', id => {
77
+ if (mapId === id) {
77
78
  me.un(listenerId);
78
79
  me.addMarker(data);
79
80
  }
80
81
  })
81
82
  } else {
82
- Neo.ns(`${data.mapId}`, true, me.markers);
83
+ Neo.ns(`${mapId}`, true, me.markers);
83
84
 
84
- me.markers[data.mapId][data.id] = marker = new google.maps.Marker({
85
- map : me.maps[data.mapId],
86
- neoId : data.id, // custom property
87
- neoMapId: data.mapId, // custom property
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
88
89
  position: data.position,
89
90
  title : data.title,
90
91
  });
@@ -105,9 +106,11 @@ class GoogleMaps extends Base {
105
106
  * @param {Boolean} data.zoomControl
106
107
  */
107
108
  create(data) {
108
- let me = this;
109
+ let me = this,
110
+ id = data.id,
111
+ map;
109
112
 
110
- me.maps[data.id] = new google.maps.Map(DomAccess.getElement(data.id), {
113
+ me.maps[id] = map = new google.maps.Map(DomAccess.getElement(id), {
111
114
  center : data.center,
112
115
  fullscreenControl: data.fullscreenControl,
113
116
  maxZoom : data.maxZoom,
@@ -117,7 +120,9 @@ class GoogleMaps extends Base {
117
120
  ...data.mapOptions
118
121
  });
119
122
 
120
- me.fire('mapCreated', data.id);
123
+ map.addListener('zoom_changed', me.onMapZoomChange.bind(me, map, id));
124
+
125
+ me.fire('mapCreated', id);
121
126
  }
122
127
 
123
128
  /**
@@ -140,6 +145,19 @@ class GoogleMaps extends Base {
140
145
  })
141
146
  }
142
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
+
143
161
  /**
144
162
  * @param {google.maps.Marker} marker
145
163
  * @param {Object} event