@cashub/ui 0.25.0 → 0.25.2

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 (2) hide show
  1. package/map/GoogleMap.js +40 -24
  2. package/package.json +1 -1
package/map/GoogleMap.js CHANGED
@@ -159,32 +159,39 @@ const Map = _ref2 => {
159
159
  if (map) {
160
160
  map.setOptions(options);
161
161
  window.google.maps.event.addListenerOnce(map, 'idle', () => {
162
- if (bounds.length === 1) {
163
- // there is only one location, locate it
164
- map.setCenter(bounds[0]);
165
- } else if (locations.length > 0) {
166
- // locate to the center of all coordinates on first load
167
- const latLngBounds = new window.google.maps.LatLngBounds();
168
- bounds.forEach(bound => {
169
- latLngBounds.extend(bound);
162
+ if (geoFence) {
163
+ map.setCenter({
164
+ lat: geoFenceOptions.latitude,
165
+ lng: geoFenceOptions.longitude
170
166
  });
171
- map.fitBounds(latLngBounds);
172
- const found = locations.find(location => {
173
- return latLngBounds.contains({
174
- lat: location.latitude,
175
- lng: location.longitude
167
+ } else {
168
+ if (bounds.length === 1) {
169
+ // there is only one location, locate it
170
+ map.setCenter(bounds[0]);
171
+ } else if (locations.length > 0) {
172
+ // locate to the center of all coordinates on first load
173
+ const latLngBounds = new window.google.maps.LatLngBounds();
174
+ bounds.forEach(bound => {
175
+ latLngBounds.extend(bound);
176
+ });
177
+ map.fitBounds(latLngBounds);
178
+ const found = locations.find(location => {
179
+ return latLngBounds.contains({
180
+ lat: location.latitude,
181
+ lng: location.longitude
182
+ });
176
183
  });
177
- });
178
184
 
179
- // if center no contain any marker then locate to first location
180
- if (!found) {
181
- map.setCenter(bounds[0]);
185
+ // if center no contain any marker then locate to first location
186
+ if (!found) {
187
+ map.setCenter(bounds[0]);
188
+ }
189
+ } else {
190
+ map.setCenter({
191
+ lat: position && position.latitude || defaultPosition.latitude,
192
+ lng: position && position.longitude || defaultPosition.longitude
193
+ });
182
194
  }
183
- } else {
184
- map.setCenter({
185
- lat: position && position.latitude || defaultPosition.latitude,
186
- lng: position && position.longitude || defaultPosition.longitude
187
- });
188
195
  }
189
196
  });
190
197
  return () => {
@@ -341,8 +348,9 @@ const Map = _ref2 => {
341
348
  });
342
349
  }
343
350
  }
351
+ let repositionButton;
344
352
  if (geoFenceOptions.enabledReposition) {
345
- const repositionButton = document.createElement('button');
353
+ repositionButton = document.createElement('button');
346
354
  repositionButton.style.margin = 'var(--spacing-s)';
347
355
  repositionButton.style.padding = 'var(--spacing-xs)';
348
356
  repositionButton.style.boxShadow = 'rgba(0, 0, 0, 0.3) 0px 1px 4px -1px';
@@ -360,13 +368,21 @@ const Map = _ref2 => {
360
368
  lng: geoFenceOptions.longitude
361
369
  });
362
370
  });
363
- map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(repositionButton);
371
+ const controlDiv = document.createElement('div');
372
+ controlDiv.appendChild(repositionButton);
373
+ map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(controlDiv);
364
374
  }
365
375
  return () => {
366
376
  circle.setMap(null);
367
377
  window.google.maps.event.clearListeners(circle, 'click');
368
378
  window.google.maps.event.clearListeners(circle, 'radius_changed');
369
379
  window.google.maps.event.clearListeners(circle, 'center_changed');
380
+
381
+ // remove reposition button if exist
382
+ const rightBottonControls = map.controls[google.maps.ControlPosition.RIGHT_BOTTOM];
383
+ if (rightBottonControls.getAt(0)) {
384
+ rightBottonControls.removeAt(0);
385
+ }
370
386
  };
371
387
  }
372
388
  }, [map, geoFence, geoFenceOptions.latitude, geoFenceOptions.longitude, geoFenceOptions.radius, geoFenceOptions.minRadius, geoFenceOptions.editable, geoFenceOptions.eventHandlers]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cashub/ui",
3
- "version": "0.25.0",
3
+ "version": "0.25.2",
4
4
  "private": false,
5
5
  "author": "CasHUB Team",
6
6
  "description": "CasHUB UI components library",