awing-library 2.1.185-dev → 2.1.186-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 }: IGoogleMapProps) => import("react/jsx-runtime").JSX.Element;
2
+ declare const GGMap: ({ defaultLocation, onUpdateLocation, apiKey, markerPosition, geofenceRadius, sizeMap, sxMap, isDisplayAutoComplete, isTypeTracking, }: IGoogleMapProps) => import("react/jsx-runtime").JSX.Element;
3
3
  export default GGMap;
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
@@ -9,20 +20,28 @@ var api_1 = require("@react-google-maps/api");
9
20
  var lodash_1 = __importDefault(require("lodash"));
10
21
  var react_1 = require("react");
11
22
  var react_i18next_1 = require("react-i18next");
23
+ var utils_1 = require("./utils");
12
24
  var mapContainerStyle = {
13
25
  height: '320px',
14
26
  width: '100%',
15
27
  };
16
28
  var libraries = ['places'];
29
+ var stylesDefault = {
30
+ position: 'relative',
31
+ '& .pac-container.pac-logo': {
32
+ top: "55px!important",
33
+ left: "0!important",
34
+ }
35
+ };
17
36
  var GGMap = function (_a) {
18
37
  var _b, _c;
19
- var defaultLocation = _a.defaultLocation, onUpdateLocation = _a.onUpdateLocation, apiKey = _a.apiKey, markerPosition = _a.markerPosition, geofenceRadius = _a.geofenceRadius;
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;
20
39
  var t = (0, react_i18next_1.useTranslation)().t;
21
- var _d = (0, react_1.useState)(), map = _d[0], setMap = _d[1];
22
- var _e = (0, react_1.useState)(''), error = _e[0], setError = _e[1];
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];
23
42
  var autocompleteRef = (0, react_1.useRef)(null);
24
43
  var boxRef = (0, react_1.useRef)(null);
25
- var _f = (0, react_1.useState)(15), zoom = _f[0], setZoom = _f[1];
44
+ var _h = (0, react_1.useState)(15), zoom = _h[0], setZoom = _h[1];
26
45
  var onLoad = function (autocomplete) {
27
46
  autocompleteRef.current = autocomplete;
28
47
  };
@@ -33,7 +52,7 @@ var GGMap = function (_a) {
33
52
  if (place.geometry) {
34
53
  var newLat = (_b = (_a = place === null || place === void 0 ? void 0 : place.geometry) === null || _a === void 0 ? void 0 : _a.location) === null || _b === void 0 ? void 0 : _b.lat();
35
54
  var newLng = (_d = (_c = place === null || place === void 0 ? void 0 : place.geometry) === null || _c === void 0 ? void 0 : _c.location) === null || _d === void 0 ? void 0 : _d.lng();
36
- onUpdateLocation({
55
+ onUpdateLocation && onUpdateLocation({
37
56
  latitude: newLat !== null && newLat !== void 0 ? newLat : 0,
38
57
  longitude: newLng !== null && newLng !== void 0 ? newLng : 0,
39
58
  });
@@ -48,41 +67,10 @@ var GGMap = function (_a) {
48
67
  var onLoadMap = function (mapInstance) {
49
68
  setMap(mapInstance);
50
69
  };
51
- //Lấy geo fencing
52
- // const getDistance = (
53
- // lat1: number,
54
- // lon1: number,
55
- // lat2: number,
56
- // lon2: number
57
- // ) => {
58
- // const R = 6371e3; // Radius of the Earth in meters
59
- // const φ1 = (lat1 * Math.PI) / 180;
60
- // const φ2 = (lat2 * Math.PI) / 180;
61
- // const Δφ = ((lat2 - lat1) * Math.PI) / 180;
62
- // const Δλ = ((lon2 - lon1) * Math.PI) / 180;
63
- // const a =
64
- // Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
65
- // Math.cos(φ1) * Math.cos(φ2) * Math.sin(Δλ / 2) * Math.sin(Δλ / 2);
66
- // const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
67
- // const distance = R * c; // Distance in meters
68
- // return distance;
69
- // };
70
70
  //Lấy vị trí hiện tại của người dùng
71
71
  var getCurrentLocation = function () {
72
- var handleLocationGeoFencing = function (position) {
73
- var userLat = position.coords.latitude;
74
- var userLng = position.coords.longitude;
75
- // const distance = getDistance(
76
- // userLat,
77
- // userLng,
78
- // markerPosition.lat,
79
- // markerPosition.lng
80
- // );
81
- // console.log("distance", distance);
82
- };
83
72
  var showPosition = function (position) {
84
- handleLocationGeoFencing(position);
85
- onUpdateLocation({
73
+ onUpdateLocation && onUpdateLocation({
86
74
  latitude: position.coords.latitude,
87
75
  longitude: position.coords.longitude,
88
76
  });
@@ -112,7 +100,7 @@ var GGMap = function (_a) {
112
100
  };
113
101
  var onMapClick = function (e) {
114
102
  var _a, _b, _c, _d;
115
- onUpdateLocation({
103
+ onUpdateLocation && onUpdateLocation({
116
104
  latitude: (_b = (_a = e === null || e === void 0 ? void 0 : e.latLng) === null || _a === void 0 ? void 0 : _a.lat()) !== null && _b !== void 0 ? _b : 0,
117
105
  longitude: (_d = (_c = e === null || e === void 0 ? void 0 : e.latLng) === null || _c === void 0 ? void 0 : _c.lng()) !== null && _d !== void 0 ? _d : 0,
118
106
  });
@@ -123,40 +111,44 @@ var GGMap = function (_a) {
123
111
  }
124
112
  }, [defaultLocation]);
125
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 };
126
- return ((0, jsx_runtime_1.jsx)(material_1.Box, { sx: {
127
- position: 'relative',
128
- '& .pac-container.pac-logo': {
129
- top: "55px!important",
130
- left: "0!important",
131
- }
132
- }, ref: boxRef, children: (0, jsx_runtime_1.jsxs)(api_1.LoadScript, { googleMapsApiKey: apiKey || '', libraries: libraries, children: [(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 () {
133
- var _a;
134
- var ggSuggest = document.querySelector('.pac-container.pac-logo');
135
- if (ggSuggest) {
136
- (_a = boxRef.current) === null || _a === void 0 ? void 0 : _a.append(ggSuggest);
137
- }
138
- }, style: {
139
- boxSizing: "border-box",
140
- border: "1px solid transparent",
141
- width: "378px",
142
- height: "40px",
143
- padding: "0 12px",
144
- borderRadius: "3px",
145
- boxShadow: "0 2px 6px rgba(0, 0, 0, 0.3)",
146
- fontSize: "14px",
147
- outline: "none",
148
- textOverflow: "ellipses",
149
- position: 'inherit',
150
- right: '3%',
151
- margin: '10px 0',
152
- zIndex: 99,
153
- top: '50px',
154
- } }) }), (0, jsx_runtime_1.jsx)(api_1.GoogleMap, { id: "map", mapContainerStyle: mapContainerStyle, zoom: zoom, center: marker, onLoad: onLoadMap, onClick: onMapClick, 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: {
114
+ 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
+ ((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
+ var _a;
117
+ var ggSuggest = document.querySelector('.pac-container.pac-logo');
118
+ if (ggSuggest) {
119
+ (_a = boxRef.current) === null || _a === void 0 ? void 0 : _a.append(ggSuggest);
120
+ }
121
+ }, style: {
122
+ boxSizing: "border-box",
123
+ border: "1px solid transparent",
124
+ width: "378px",
125
+ height: "40px",
126
+ padding: "0 12px",
127
+ borderRadius: "3px",
128
+ boxShadow: "0 2px 6px rgba(0, 0, 0, 0.3)",
129
+ fontSize: "14px",
130
+ outline: "none",
131
+ textOverflow: "ellipses",
132
+ position: 'inherit',
133
+ right: '3%',
134
+ margin: '10px 0',
135
+ zIndex: 99,
136
+ top: '50px',
137
+ } }) })), (0, jsx_runtime_1.jsx)(api_1.GoogleMap, __assign({ id: "map", mapContainerStyle: sizeMap !== null && sizeMap !== void 0 ? sizeMap : mapContainerStyle, zoom: zoom, center: marker, onLoad: onLoadMap, onClick: onMapClick }, isTypeTracking && {
138
+ options: {
139
+ disableDefaultUI: true,
140
+ styles: utils_1.mapStyles,
141
+ zoomControl: true,
142
+ streetViewControl: false,
143
+ mapTypeControl: false,
144
+ fullscreenControl: false,
145
+ }
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: {
155
147
  fillColor: 'red',
156
148
  fillOpacity: 0.2,
157
149
  strokeColor: 'red',
158
150
  strokeOpacity: 1,
159
151
  strokeWeight: 2,
160
- } })] }) })] }) }));
152
+ } })] }) }))] }) }));
161
153
  };
162
154
  exports.default = GGMap;
@@ -1,3 +1,4 @@
1
+ import { DataObject } from "../../AWING/interface";
1
2
  export interface IGoogleMapProps {
2
3
  defaultLocation?: {
3
4
  lat: number;
@@ -7,10 +8,17 @@ export interface IGoogleMapProps {
7
8
  latitude: number;
8
9
  longitude: number;
9
10
  };
10
- onUpdateLocation: (newValue: {
11
+ onUpdateLocation?: (newValue: {
11
12
  latitude: number;
12
13
  longitude: number;
13
14
  }) => void;
14
15
  apiKey: string;
15
16
  geofenceRadius?: number;
17
+ sizeMap?: {
18
+ height: string;
19
+ width: string;
20
+ };
21
+ sxMap?: DataObject;
22
+ isDisplayAutoComplete?: boolean;
23
+ isTypeTracking?: boolean;
16
24
  }
@@ -0,0 +1,25 @@
1
+ export declare const mapStyles: ({
2
+ elementType: string;
3
+ stylers: {
4
+ color: string;
5
+ }[];
6
+ featureType?: undefined;
7
+ } | {
8
+ elementType: string;
9
+ stylers: {
10
+ visibility: string;
11
+ }[];
12
+ featureType?: undefined;
13
+ } | {
14
+ featureType: string;
15
+ elementType: string;
16
+ stylers: {
17
+ color: string;
18
+ }[];
19
+ } | {
20
+ featureType: string;
21
+ stylers: {
22
+ visibility: string;
23
+ }[];
24
+ elementType?: undefined;
25
+ })[];
@@ -0,0 +1,135 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapStyles = void 0;
4
+ exports.mapStyles = [
5
+ {
6
+ "elementType": "geometry",
7
+ "stylers": [
8
+ {
9
+ "color": "#dadce0"
10
+ }
11
+ ]
12
+ },
13
+ {
14
+ "elementType": "labels.icon",
15
+ "stylers": [
16
+ {
17
+ "visibility": "off"
18
+ }
19
+ ]
20
+ },
21
+ {
22
+ "elementType": "labels.text.fill",
23
+ "stylers": [
24
+ {
25
+ "color": "#212225"
26
+ }
27
+ ]
28
+ },
29
+ {
30
+ "elementType": "labels.text.stroke",
31
+ "stylers": [
32
+ {
33
+ "color": "#dadce0"
34
+ }
35
+ ]
36
+ },
37
+ {
38
+ "featureType": "administrative",
39
+ "elementType": "geometry",
40
+ "stylers": [
41
+ {
42
+ "color": "#212225"
43
+ }
44
+ ]
45
+ },
46
+ {
47
+ "featureType": "administrative.country",
48
+ "elementType": "labels.text.fill",
49
+ "stylers": [
50
+ {
51
+ "color": "#212225"
52
+ }
53
+ ]
54
+ },
55
+ {
56
+ "featureType": "administrative.land_parcel",
57
+ "stylers": [
58
+ {
59
+ "visibility": "off"
60
+ }
61
+ ]
62
+ },
63
+ {
64
+ "featureType": "administrative.locality",
65
+ "elementType": "labels.text.fill",
66
+ "stylers": [
67
+ {
68
+ "color": "#898989"
69
+ }
70
+ ]
71
+ },
72
+ {
73
+ "featureType": "poi",
74
+ "elementType": "labels.text.fill",
75
+ "stylers": [
76
+ {
77
+ "color": "#212225"
78
+ }
79
+ ]
80
+ },
81
+ {
82
+ "featureType": "poi.park",
83
+ "elementType": "labels.text.fill",
84
+ "stylers": [
85
+ {
86
+ "color": "#616161"
87
+ }
88
+ ]
89
+ },
90
+ {
91
+ "featureType": "road",
92
+ "elementType": "geometry.fill",
93
+ "stylers": [
94
+ {
95
+ "color": "#c8c8c8"
96
+ }
97
+ ]
98
+ },
99
+ {
100
+ "featureType": "road",
101
+ "elementType": "labels.text.fill",
102
+ "stylers": [
103
+ {
104
+ "color": "#8a8a8a"
105
+ }
106
+ ]
107
+ },
108
+ {
109
+ "featureType": "transit",
110
+ "elementType": "labels.text.fill",
111
+ "stylers": [
112
+ {
113
+ "color": "#212225"
114
+ }
115
+ ]
116
+ },
117
+ {
118
+ "featureType": "water",
119
+ "elementType": "geometry",
120
+ "stylers": [
121
+ {
122
+ "color": "#f8f9fa"
123
+ }
124
+ ]
125
+ },
126
+ {
127
+ "featureType": "water",
128
+ "elementType": "labels.text.fill",
129
+ "stylers": [
130
+ {
131
+ "color": "#f8f9fa"
132
+ }
133
+ ]
134
+ }
135
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "awing-library",
3
- "version": "2.1.185-dev",
3
+ "version": "2.1.186-dev",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",