awing-library 2.1.186-dev → 2.1.187-dev

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.
@@ -1,3 +1,3 @@
1
1
  import { IGoogleMapProps } from './interface';
2
- declare const GGMap: ({ defaultLocation, onUpdateLocation, apiKey, markerPosition, geofenceRadius, sizeMap, sxMap, isDisplayAutoComplete, isTypeTracking, }: IGoogleMapProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare const GGMap: ({ defaultLocation, onUpdateLocation, apiKey, markerPosition, geofenceRadius, sizeMap, sxMap, isDisplayAutoComplete, isTypeTracking, markerPositions, zoomCustomed }: IGoogleMapProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default GGMap;
@@ -34,14 +34,13 @@ var stylesDefault = {
34
34
  }
35
35
  };
36
36
  var GGMap = function (_a) {
37
- var _b, _c;
38
- var defaultLocation = _a.defaultLocation, onUpdateLocation = _a.onUpdateLocation, apiKey = _a.apiKey, markerPosition = _a.markerPosition, geofenceRadius = _a.geofenceRadius, sizeMap = _a.sizeMap, sxMap = _a.sxMap, _d = _a.isDisplayAutoComplete, isDisplayAutoComplete = _d === void 0 ? false : _d, _e = _a.isTypeTracking, isTypeTracking = _e === void 0 ? false : _e;
37
+ var defaultLocation = _a.defaultLocation, onUpdateLocation = _a.onUpdateLocation, apiKey = _a.apiKey, markerPosition = _a.markerPosition, geofenceRadius = _a.geofenceRadius, sizeMap = _a.sizeMap, sxMap = _a.sxMap, _b = _a.isDisplayAutoComplete, isDisplayAutoComplete = _b === void 0 ? false : _b, _c = _a.isTypeTracking, isTypeTracking = _c === void 0 ? false : _c, markerPositions = _a.markerPositions, zoomCustomed = _a.zoomCustomed;
39
38
  var t = (0, react_i18next_1.useTranslation)().t;
40
- var _f = (0, react_1.useState)(), map = _f[0], setMap = _f[1];
41
- var _g = (0, react_1.useState)(''), error = _g[0], setError = _g[1];
39
+ var _d = (0, react_1.useState)(), map = _d[0], setMap = _d[1];
40
+ var _e = (0, react_1.useState)(''), error = _e[0], setError = _e[1];
42
41
  var autocompleteRef = (0, react_1.useRef)(null);
43
42
  var boxRef = (0, react_1.useRef)(null);
44
- var _h = (0, react_1.useState)(15), zoom = _h[0], setZoom = _h[1];
43
+ var _f = (0, react_1.useState)(zoomCustomed || 0), zoom = _f[0], setZoom = _f[1];
45
44
  var onLoad = function (autocomplete) {
46
45
  autocompleteRef.current = autocomplete;
47
46
  };
@@ -110,7 +109,13 @@ var GGMap = function (_a) {
110
109
  getCurrentLocation();
111
110
  }
112
111
  }, [defaultLocation]);
113
- var marker = { lat: (_b = Number(markerPosition === null || markerPosition === void 0 ? void 0 : markerPosition.latitude)) !== null && _b !== void 0 ? _b : 0, lng: (_c = Number(markerPosition === null || markerPosition === void 0 ? void 0 : markerPosition.longitude)) !== null && _c !== void 0 ? _c : 0 };
112
+ var marker = (0, react_1.useMemo)(function () {
113
+ var _a, _b;
114
+ return {
115
+ lat: (_a = Number(markerPosition === null || markerPosition === void 0 ? void 0 : markerPosition.latitude)) !== null && _a !== void 0 ? _a : 0,
116
+ lng: (_b = Number(markerPosition === null || markerPosition === void 0 ? void 0 : markerPosition.longitude)) !== null && _b !== void 0 ? _b : 0,
117
+ };
118
+ }, [markerPosition]);
114
119
  return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: sxMap ? sxMap : stylesDefault, ref: boxRef, children: (0, jsx_runtime_1.jsxs)(api_1.LoadScript, { googleMapsApiKey: apiKey || '', libraries: libraries, children: [!isDisplayAutoComplete &&
115
120
  ((0, jsx_runtime_1.jsx)(api_1.Autocomplete, { onPlaceChanged: onPlaceChanged, onLoad: onLoad, children: (0, jsx_runtime_1.jsx)("input", { type: "text", placeholder: t('Common.PlaceHolderLocation'), onFocus: function () {
116
121
  var _a;
@@ -143,12 +148,25 @@ var GGMap = function (_a) {
143
148
  mapTypeControl: false,
144
149
  fullscreenControl: false,
145
150
  }
146
- }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(api_1.Marker, { position: marker }), (0, jsx_runtime_1.jsx)(api_1.Circle, { center: marker, radius: geofenceRadius, options: {
147
- fillColor: 'red',
148
- fillOpacity: 0.2,
149
- strokeColor: 'red',
150
- strokeOpacity: 1,
151
- strokeWeight: 2,
152
- } })] }) }))] }) }));
151
+ }, { children: !markerPositions ?
152
+ (0, jsx_runtime_1.jsxs)(material_1.Box, { children: [(0, jsx_runtime_1.jsx)(api_1.Marker, { position: marker }), (0, jsx_runtime_1.jsx)(api_1.Circle, { center: marker, radius: geofenceRadius, options: {
153
+ fillColor: 'red',
154
+ fillOpacity: 0.2,
155
+ strokeColor: 'red',
156
+ strokeOpacity: 1,
157
+ strokeWeight: 2,
158
+ } })] })
159
+ : (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: markerPositions === null || markerPositions === void 0 ? void 0 : markerPositions.map(function (coordinates, index, positions) {
160
+ var _a, _b;
161
+ // const radius =
162
+ // Math.max(
163
+ // 30,
164
+ // (coordinates.count /
165
+ // Math.max(...positions.map((p) => p.count))) *
166
+ // 120
167
+ // ) *
168
+ // (1 / 7);
169
+ return (0, jsx_runtime_1.jsx)(api_1.Marker, { position: { lat: (_a = coordinates.latitude) !== null && _a !== void 0 ? _a : 0, lng: (_b = coordinates.longitude) !== null && _b !== void 0 ? _b : 0 } }, index);
170
+ }) }) }))] }) }));
153
171
  };
154
172
  exports.default = GGMap;
@@ -21,4 +21,9 @@ export interface IGoogleMapProps {
21
21
  sxMap?: DataObject;
22
22
  isDisplayAutoComplete?: boolean;
23
23
  isTypeTracking?: boolean;
24
+ markerPositions?: {
25
+ longitude: number | null;
26
+ latitude: number | null;
27
+ }[];
28
+ zoomCustomed?: number;
24
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.186-dev",
3
+ "version": "2.1.187-dev",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",