mapping-component-package-jp 0.0.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.
- package/README.md +70 -0
- package/dist/index.d.ts +264 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +54 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +48 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/rollup.config.js +48 -0
- package/src/components/FabControl.tsx +63 -0
- package/src/components/GoogleSearchBar.tsx +182 -0
- package/src/components/Icons.tsx +20 -0
- package/src/components/JPMapComponent.tsx +96 -0
- package/src/components/SpeedDialTool.tsx +97 -0
- package/src/components/index.ts +22 -0
- package/src/hooks/useMapManager.ts +48 -0
- package/src/interfaces/AgnifyMapComponentProps.ts +18 -0
- package/src/interfaces/CustomMapOptions.ts +14 -0
- package/src/interfaces/Data/EnterpriseRegion.ts +12 -0
- package/src/interfaces/Data/Farm.ts +10 -0
- package/src/interfaces/Data/Field.ts +19 -0
- package/src/interfaces/Data/LocationData.ts +9 -0
- package/src/interfaces/Data/MapLocationFeature.ts +8 -0
- package/src/interfaces/Data/NDVI.ts +14 -0
- package/src/interfaces/GoogleMapsOptions.ts +39 -0
- package/src/interfaces/Message.ts +13 -0
- package/src/interfaces/Mode.ts +54 -0
- package/src/interfaces/Properties.ts +16 -0
- package/src/js/fieldEncapsulation/iql.field.js +8 -0
- package/src/js/fieldEncapsulation/iql.fieldupload.js +158 -0
- package/src/js/fieldEncapsulation/iql.fieldvalidator.js +574 -0
- package/src/js/mapEncapsulation/circle.functions.js +30 -0
- package/src/js/mapEncapsulation/field.geolocation.js +19 -0
- package/src/js/mapEncapsulation/map.common.js +96 -0
- package/src/js/mapEncapsulation/mapOverlayManager.d.ts +64 -0
- package/src/js/mapEncapsulation/mapOverlayManager.js +2753 -0
- package/src/js/mapEncapsulation/shapes/circle.full.js +789 -0
- package/src/js/mapEncapsulation/shapes/circle.sector.js +1099 -0
- package/src/js/mapEncapsulation/shapes/circle.segment.js +1109 -0
- package/src/js/mapEncapsulation/shapes/polygon.customedit.js +393 -0
- package/src/js/mapEncapsulation/shapes/polyline.customedit.js +478 -0
- package/src/utils/commonUtils.ts +5 -0
- package/src/utils/iconUtils.js +52 -0
- package/src/utils/mapUtils.ts +88 -0
- package/tsconfig.json +20 -0
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mapping-component-package-jp",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
+
"rollup": "rollup -c --bundleConfigAsCjs",
|
|
11
|
+
"build": "rollup -c --bundleConfigAsCjs",
|
|
12
|
+
"prepublishOnly": "npm run build",
|
|
13
|
+
"vp": "npm version patch",
|
|
14
|
+
"vm": "npm version minor",
|
|
15
|
+
"vj": "npm version major"
|
|
16
|
+
},
|
|
17
|
+
"author": "",
|
|
18
|
+
"license": "ISC",
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@mapbox/polyline": "^1.2.1",
|
|
21
|
+
"@rollup/plugin-image": "^3.0.3",
|
|
22
|
+
"@rollup/plugin-url": "^8.0.2",
|
|
23
|
+
"@types/mapbox__polyline": "^1.0.5",
|
|
24
|
+
"@types/react": "^18.3.11",
|
|
25
|
+
"@types/uuid": "^10.0.0",
|
|
26
|
+
"install": "^0.13.0",
|
|
27
|
+
"polylabel": "^2.0.1",
|
|
28
|
+
"polyline": "^0.2.0",
|
|
29
|
+
"react": "^18.3.1",
|
|
30
|
+
"tslib": "^2.7.0",
|
|
31
|
+
"typescript": "^5.6.3"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@emotion/react": "^11.13.3",
|
|
35
|
+
"@emotion/styled": "^11.13.0",
|
|
36
|
+
"@mui/icons-material": "^6.1.4",
|
|
37
|
+
"@mui/material": "^6.1.4",
|
|
38
|
+
"@react-google-maps/api": "^2.19.3",
|
|
39
|
+
"@rollup/plugin-commonjs": "^28.0.0",
|
|
40
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
41
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
42
|
+
"@rollup/plugin-typescript": "^12.1.0",
|
|
43
|
+
"rollup-plugin-dts": "^6.1.1",
|
|
44
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
45
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
46
|
+
"uuid": "^10.0.0"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<meta name="theme-color" content="#000000" />
|
|
8
|
+
<meta
|
|
9
|
+
name="description"
|
|
10
|
+
content="Web site created using create-react-app"
|
|
11
|
+
/>
|
|
12
|
+
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
|
|
13
|
+
<!--
|
|
14
|
+
manifest.json provides metadata used when your web app is installed on a
|
|
15
|
+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
|
|
16
|
+
-->
|
|
17
|
+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
|
|
18
|
+
<!--
|
|
19
|
+
Notice the use of %PUBLIC_URL% in the tags above.
|
|
20
|
+
It will be replaced with the URL of the `public` folder during the build.
|
|
21
|
+
Only files inside the `public` folder can be referenced from the HTML.
|
|
22
|
+
|
|
23
|
+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
|
24
|
+
work correctly both with client-side routing and a non-root public URL.
|
|
25
|
+
Learn how to configure a non-root public URL by running `npm run build`.
|
|
26
|
+
-->
|
|
27
|
+
<title>React App</title>
|
|
28
|
+
</head>
|
|
29
|
+
<body>
|
|
30
|
+
<noscript>You need to enable JavaScript to run this app.</noscript>
|
|
31
|
+
<div id="root"></div>
|
|
32
|
+
<!--
|
|
33
|
+
This HTML file is a template.
|
|
34
|
+
If you open it directly in the browser, you will see an empty page.
|
|
35
|
+
|
|
36
|
+
You can add webfonts, meta tags, or analytics to this file.
|
|
37
|
+
The build step will place the bundled scripts into the <body> tag.
|
|
38
|
+
|
|
39
|
+
To begin the development, run `npm start` or `yarn start`.
|
|
40
|
+
To create a production bundle, use `npm run build` or `yarn build`.
|
|
41
|
+
-->
|
|
42
|
+
</body>
|
|
43
|
+
</html>
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"short_name": "React App",
|
|
3
|
+
"name": "Create React App Sample",
|
|
4
|
+
"icons": [
|
|
5
|
+
{
|
|
6
|
+
"src": "favicon.ico",
|
|
7
|
+
"sizes": "64x64 32x32 24x24 16x16",
|
|
8
|
+
"type": "image/x-icon"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"src": "logo192.png",
|
|
12
|
+
"type": "image/png",
|
|
13
|
+
"sizes": "192x192"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"src": "logo512.png",
|
|
17
|
+
"type": "image/png",
|
|
18
|
+
"sizes": "512x512"
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"start_url": ".",
|
|
22
|
+
"display": "standalone",
|
|
23
|
+
"theme_color": "#000000",
|
|
24
|
+
"background_color": "#ffffff"
|
|
25
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import resolve from "@rollup/plugin-node-resolve";
|
|
2
|
+
import commonjs from "@rollup/plugin-commonjs";
|
|
3
|
+
import typescript from "@rollup/plugin-typescript";
|
|
4
|
+
import dts from "rollup-plugin-dts";
|
|
5
|
+
import terser from "@rollup/plugin-terser";
|
|
6
|
+
import peerDepsExternal from "rollup-plugin-peer-deps-external";
|
|
7
|
+
import postcss from "rollup-plugin-postcss";
|
|
8
|
+
import url from "@rollup/plugin-url";
|
|
9
|
+
|
|
10
|
+
const packageJson = require("./package.json");
|
|
11
|
+
|
|
12
|
+
export default [
|
|
13
|
+
{
|
|
14
|
+
input: "src/components/index.ts",
|
|
15
|
+
output: [
|
|
16
|
+
{
|
|
17
|
+
file: packageJson.main,
|
|
18
|
+
format: "cjs",
|
|
19
|
+
sourcemap: true,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
file: packageJson.module,
|
|
23
|
+
format: "esm",
|
|
24
|
+
sourcemap: true,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
plugins: [
|
|
28
|
+
peerDepsExternal(),
|
|
29
|
+
resolve(),
|
|
30
|
+
commonjs(),
|
|
31
|
+
typescript({ tsconfig: "./tsconfig.json" }),
|
|
32
|
+
terser(),
|
|
33
|
+
postcss(),
|
|
34
|
+
url({
|
|
35
|
+
include: ['**/*.svg', '**/*.png', '**/*.jpg', '**/*.jpeg', '**/*.gif'],
|
|
36
|
+
limit: 0,
|
|
37
|
+
fileName: '[dirname][hash][extname]',
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
40
|
+
external: ["react", "react-dom"],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
input: "src/components/index.ts",
|
|
44
|
+
output: [{ file: packageJson.types }],
|
|
45
|
+
plugins: [dts.default()],
|
|
46
|
+
external: [/\.css$/],
|
|
47
|
+
},
|
|
48
|
+
];
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Fab, styled } from '@mui/material';
|
|
3
|
+
|
|
4
|
+
interface FabButtonProps {
|
|
5
|
+
icon: React.ReactNode;
|
|
6
|
+
size?: 'small' | 'medium' | 'large';
|
|
7
|
+
onClick?: () => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface FabControlProps {
|
|
11
|
+
buttons: FabButtonProps[];
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const defaultStyles: React.CSSProperties = {
|
|
16
|
+
position: 'absolute',
|
|
17
|
+
bottom: '16px',
|
|
18
|
+
left: '16px',
|
|
19
|
+
color: '#F1A81E',
|
|
20
|
+
zIndex: 1000,
|
|
21
|
+
display: 'flex',
|
|
22
|
+
flexDirection: 'column',
|
|
23
|
+
gap: '8px',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const StyledFab = styled(Fab)<{ bgcolor?: string }>(({ bgcolor }) => ({
|
|
27
|
+
marginBottom: '8px',
|
|
28
|
+
backgroundColor: bgcolor,
|
|
29
|
+
width: '56px',
|
|
30
|
+
height: '56px',
|
|
31
|
+
'& .MuiSvgIcon-root': {
|
|
32
|
+
fontSize: '24px',
|
|
33
|
+
},
|
|
34
|
+
'&:hover': {
|
|
35
|
+
backgroundColor: bgcolor,
|
|
36
|
+
opacity: 0.9,
|
|
37
|
+
},
|
|
38
|
+
'&:last-child': {
|
|
39
|
+
marginBottom: 0,
|
|
40
|
+
},
|
|
41
|
+
}));
|
|
42
|
+
|
|
43
|
+
const FabControl: React.FC<FabControlProps> = ({ buttons, style }) => {
|
|
44
|
+
const mergedStyles = { ...defaultStyles, ...style };
|
|
45
|
+
const backgroundColor = mergedStyles.color;
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div style={mergedStyles}>
|
|
49
|
+
{buttons.map((button, index) => (
|
|
50
|
+
<StyledFab
|
|
51
|
+
key={index}
|
|
52
|
+
size={button.size || 'medium'}
|
|
53
|
+
onClick={button.onClick}
|
|
54
|
+
bgcolor={backgroundColor}
|
|
55
|
+
>
|
|
56
|
+
{button.icon}
|
|
57
|
+
</StyledFab>
|
|
58
|
+
))}
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default FabControl;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { TextField, IconButton , CircularProgress, InputAdornment, Autocomplete } from '@mui/material';
|
|
3
|
+
import RoomIcon from '@mui/icons-material/Room';
|
|
4
|
+
import CloseIcon from '@mui/icons-material/Close';
|
|
5
|
+
import { Properties } from '../interfaces/Properties';
|
|
6
|
+
|
|
7
|
+
interface GooglePlacesSearchProps {
|
|
8
|
+
map: google.maps.Map;
|
|
9
|
+
zoom?: number;
|
|
10
|
+
properties: Properties
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const GoogleSearchBar: React.FC<GooglePlacesSearchProps> = ({
|
|
14
|
+
map,
|
|
15
|
+
zoom = 15,
|
|
16
|
+
properties,
|
|
17
|
+
}) => {
|
|
18
|
+
const defaultStyle: React.CSSProperties = {
|
|
19
|
+
position: 'absolute',
|
|
20
|
+
top: '10px',
|
|
21
|
+
left: '50%',
|
|
22
|
+
transform: 'translateX(-50%)',
|
|
23
|
+
zIndex: 1000,
|
|
24
|
+
width: '400px',
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const defaultSx = {
|
|
28
|
+
'& .MuiInputBase-root': {
|
|
29
|
+
borderRadius: '15px',
|
|
30
|
+
backgroundColor: '#ffffff',
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const mergedStyle = { ...defaultStyle, ...properties.style };
|
|
35
|
+
const mergedSx = { ...defaultSx, ...properties.sx };
|
|
36
|
+
|
|
37
|
+
const inputRef = useRef<HTMLInputElement | null>(null);
|
|
38
|
+
const [isLoading, setIsLoading] = useState<boolean>(false);
|
|
39
|
+
const [inputValue, setInputValue] = useState<string>('');
|
|
40
|
+
const [suggestions, setSuggestions] = useState<google.maps.places.AutocompletePrediction[]>([]);
|
|
41
|
+
const autocompleteServiceRef = useRef<google.maps.places.AutocompleteService | null>(null);
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (window.google && window.google.maps && !autocompleteServiceRef.current) {
|
|
45
|
+
autocompleteServiceRef.current = new google.maps.places.AutocompleteService();
|
|
46
|
+
}
|
|
47
|
+
}, []);
|
|
48
|
+
|
|
49
|
+
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
50
|
+
const value = event.target.value;
|
|
51
|
+
setInputValue(value);
|
|
52
|
+
|
|
53
|
+
if (value && autocompleteServiceRef.current) {
|
|
54
|
+
autocompleteServiceRef.current.getPlacePredictions(
|
|
55
|
+
{
|
|
56
|
+
input: value,
|
|
57
|
+
componentRestrictions: { country: 'ZA' },
|
|
58
|
+
},
|
|
59
|
+
(predictions, status) => {
|
|
60
|
+
if (status === google.maps.places.PlacesServiceStatus.OK && predictions) {
|
|
61
|
+
setSuggestions(predictions);
|
|
62
|
+
} else {
|
|
63
|
+
setSuggestions([]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
} else {
|
|
68
|
+
setSuggestions([]);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const handleAddressPinClick = async () => {
|
|
73
|
+
if (!map) return;
|
|
74
|
+
|
|
75
|
+
setIsLoading(true);
|
|
76
|
+
try {
|
|
77
|
+
if (navigator.geolocation) {
|
|
78
|
+
navigator.geolocation.getCurrentPosition(async (position) => {
|
|
79
|
+
const { latitude, longitude } = position.coords;
|
|
80
|
+
|
|
81
|
+
const location = new google.maps.LatLng(latitude, longitude);
|
|
82
|
+
map.panTo(location);
|
|
83
|
+
map.setZoom(zoom);
|
|
84
|
+
|
|
85
|
+
const geocoder = new google.maps.Geocoder();
|
|
86
|
+
geocoder.geocode({ location }, (results, status) => {
|
|
87
|
+
if (status === google.maps.GeocoderStatus.OK && results && results[0]) {
|
|
88
|
+
setInputValue(results[0].formatted_address);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
} else {
|
|
93
|
+
console.error('Geolocation is not supported by this browser.');
|
|
94
|
+
}
|
|
95
|
+
} catch (error) {
|
|
96
|
+
console.error('Error fetching geolocation:', error);
|
|
97
|
+
} finally {
|
|
98
|
+
setIsLoading(false);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const handleClearInput = () => {
|
|
103
|
+
setInputValue('');
|
|
104
|
+
setSuggestions([]);
|
|
105
|
+
if (inputRef.current) {
|
|
106
|
+
inputRef.current.focus();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const handleSuggestionClick = (suggestion: google.maps.places.AutocompletePrediction) => {
|
|
111
|
+
setInputValue(suggestion.description);
|
|
112
|
+
setSuggestions([]);
|
|
113
|
+
|
|
114
|
+
const geocoder = new google.maps.Geocoder();
|
|
115
|
+
geocoder.geocode({ address: suggestion.description }, (results, status) => {
|
|
116
|
+
if (status === google.maps.GeocoderStatus.OK && results && results[0].geometry) {
|
|
117
|
+
const location = results[0].geometry.location;
|
|
118
|
+
if (map) {
|
|
119
|
+
map.panTo(location);
|
|
120
|
+
map.setZoom(zoom);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div style={mergedStyle}>
|
|
128
|
+
<Autocomplete
|
|
129
|
+
freeSolo
|
|
130
|
+
options={suggestions}
|
|
131
|
+
getOptionLabel={(option) => typeof option === 'string' ? option : option.description}
|
|
132
|
+
onInputChange={(event, value) => setInputValue(value)}
|
|
133
|
+
onChange={(event, value) => {
|
|
134
|
+
if (typeof value === 'object' && value) {
|
|
135
|
+
handleSuggestionClick(value as google.maps.places.AutocompletePrediction);
|
|
136
|
+
}
|
|
137
|
+
}}
|
|
138
|
+
inputValue={inputValue}
|
|
139
|
+
renderInput={(params) => (
|
|
140
|
+
<TextField
|
|
141
|
+
{...params}
|
|
142
|
+
inputRef={inputRef}
|
|
143
|
+
value={inputValue}
|
|
144
|
+
onChange={handleInputChange}
|
|
145
|
+
placeholder={properties.text || "Search for a location..."}
|
|
146
|
+
variant="outlined"
|
|
147
|
+
fullWidth
|
|
148
|
+
sx={mergedSx}
|
|
149
|
+
InputProps={{
|
|
150
|
+
...params.InputProps,
|
|
151
|
+
endAdornment: (
|
|
152
|
+
<InputAdornment position="end">
|
|
153
|
+
{inputValue ? (
|
|
154
|
+
<IconButton onClick={handleClearInput}>
|
|
155
|
+
<CloseIcon />
|
|
156
|
+
</IconButton>
|
|
157
|
+
) : (
|
|
158
|
+
properties.icon && (
|
|
159
|
+
<IconButton
|
|
160
|
+
onClick={handleAddressPinClick}
|
|
161
|
+
sx={properties.icon.style}
|
|
162
|
+
>
|
|
163
|
+
{isLoading ? <CircularProgress /> : <RoomIcon />}
|
|
164
|
+
</IconButton>
|
|
165
|
+
)
|
|
166
|
+
)}
|
|
167
|
+
</InputAdornment>
|
|
168
|
+
),
|
|
169
|
+
}}
|
|
170
|
+
/>
|
|
171
|
+
)}
|
|
172
|
+
renderOption={(props, option) => (
|
|
173
|
+
<li {...props} key={option.place_id} style={{ fontSize: '1rem', padding: '5px' }}>
|
|
174
|
+
{option.description}
|
|
175
|
+
</li>
|
|
176
|
+
)}
|
|
177
|
+
/>
|
|
178
|
+
</div>
|
|
179
|
+
);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export default GoogleSearchBar;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SvgIcon, SvgIconProps } from '@mui/material';
|
|
3
|
+
|
|
4
|
+
export const SolidCircleIcon: React.FC<SvgIconProps> = (props) => (
|
|
5
|
+
<SvgIcon {...props}>
|
|
6
|
+
<circle cx="12" cy="12" r="10" />
|
|
7
|
+
</SvgIcon>
|
|
8
|
+
);
|
|
9
|
+
|
|
10
|
+
export const PivotIcon: React.FC<SvgIconProps> = (props) => (
|
|
11
|
+
<SvgIcon {...props}>
|
|
12
|
+
<path d="M12 2 A 10 10 0 0 1 22 12 L 12 12 Z" />
|
|
13
|
+
</SvgIcon>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export const HalfCircleIcon: React.FC<SvgIconProps> = (props) => (
|
|
17
|
+
<SvgIcon {...props}>
|
|
18
|
+
<path d="M12 2C6.48 2 2 6.48 2 12h20c0-5.52-4.48-10-10-10z" />
|
|
19
|
+
</SvgIcon>
|
|
20
|
+
);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React, { memo, useState, useCallback, useEffect } from "react";
|
|
2
|
+
import { GoogleMap, useJsApiLoader, Libraries } from "@react-google-maps/api";
|
|
3
|
+
import { useMapManager } from "../hooks/useMapManager";
|
|
4
|
+
|
|
5
|
+
const containerStyle = {
|
|
6
|
+
width: "960px",
|
|
7
|
+
height: "480px",
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const center = {
|
|
11
|
+
lat: -25.7652061,
|
|
12
|
+
lng: 28.2710333,
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type jpMapType = {
|
|
16
|
+
isMapInitialized: boolean;
|
|
17
|
+
mapObject: google.maps.Map;
|
|
18
|
+
mapManager: any;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
interface JPMapComponentProps {
|
|
23
|
+
gmAPIkey: string,
|
|
24
|
+
jpMap: (jpMap: jpMapType) => void,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const libraries: Libraries = ['places', 'marker', 'geometry'];
|
|
28
|
+
|
|
29
|
+
const mapOptions = {
|
|
30
|
+
disableDefaultUI: true,
|
|
31
|
+
mapId: 'JP_DEMO_MAP', //needed for AdvancedMarker map capability
|
|
32
|
+
mapTypeId: 'hybrid', //this causes the reloading of tiles if const mapOptions is inside the component
|
|
33
|
+
mapTypeControl: true,
|
|
34
|
+
zoomControl: true,
|
|
35
|
+
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
const JPMapComponent: React.FC<JPMapComponentProps> = ({ gmAPIkey, jpMap }) => {
|
|
40
|
+
/*
|
|
41
|
+
const mapOptions = {
|
|
42
|
+
mapId: 'JP_DEMO_MAP', //needed for AdvancedMarker map capability
|
|
43
|
+
mapTypeId: 'hybrid', //this causes the reloading of tiles if const mapOptions is inside the component
|
|
44
|
+
};
|
|
45
|
+
*/
|
|
46
|
+
const [mapInstance, setMapInstance] = useState<google.maps.Map | null>(null);
|
|
47
|
+
|
|
48
|
+
const {
|
|
49
|
+
mapManager,
|
|
50
|
+
} = useMapManager({
|
|
51
|
+
mapInstance,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const { isLoaded } = useJsApiLoader({
|
|
55
|
+
id: "google-map-script",
|
|
56
|
+
googleMapsApiKey: gmAPIkey,//"AIzaSyAyy8BzMlKKQCPsQRgvhMW4MxfjGuIEWUc",
|
|
57
|
+
libraries: libraries
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const onLoad = useCallback(function callback(map: any) {
|
|
61
|
+
//setMap(map);
|
|
62
|
+
setMapInstance(map);
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if(mapInstance !== null) {
|
|
67
|
+
//console.log(map);
|
|
68
|
+
jpMap({ isMapInitialized: true, mapObject: mapInstance, mapManager: mapManager});
|
|
69
|
+
//isMapInitialized(true);
|
|
70
|
+
//mapObject(map);
|
|
71
|
+
}
|
|
72
|
+
}, [mapInstance, jpMap]);
|
|
73
|
+
|
|
74
|
+
const onUnmount = useCallback(function callback(map: any) {
|
|
75
|
+
setMapInstance(null);
|
|
76
|
+
}, []);
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
return isLoaded ? (
|
|
80
|
+
<GoogleMap
|
|
81
|
+
mapContainerStyle={containerStyle}
|
|
82
|
+
center={center}
|
|
83
|
+
zoom={5}
|
|
84
|
+
options={mapOptions}
|
|
85
|
+
onLoad={onLoad}
|
|
86
|
+
onUnmount={onUnmount}
|
|
87
|
+
>
|
|
88
|
+
{/* Child components, such as markers, info windows, etc. */}
|
|
89
|
+
<></>
|
|
90
|
+
</GoogleMap>
|
|
91
|
+
) : (
|
|
92
|
+
<></>
|
|
93
|
+
)
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export default memo(JPMapComponent);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SpeedDial, SpeedDialIcon, SpeedDialAction, styled } from '@mui/material';
|
|
3
|
+
import SquareIcon from '@mui/icons-material/Square';
|
|
4
|
+
import { SolidCircleIcon, HalfCircleIcon, PivotIcon } from './Icons';
|
|
5
|
+
|
|
6
|
+
interface SpeedDialToolProps {
|
|
7
|
+
style?: React.CSSProperties;
|
|
8
|
+
onSquareClick: () => void;
|
|
9
|
+
onCircleClick: () => void;
|
|
10
|
+
onCircleSectorClick: () => void;
|
|
11
|
+
onCircleSegmentClick: () => void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const defaultStyles: React.CSSProperties = {
|
|
15
|
+
position: 'absolute',
|
|
16
|
+
bottom: '16px',
|
|
17
|
+
right: '16px',
|
|
18
|
+
color: '#F1A81E',
|
|
19
|
+
zIndex: 1000,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const StyledSpeedDial = styled(SpeedDial)<{ customcolor?: string }>(({ customcolor }) => ({
|
|
23
|
+
'& .MuiFab-primary': {
|
|
24
|
+
backgroundColor: customcolor,
|
|
25
|
+
'&:hover': {
|
|
26
|
+
backgroundColor: customcolor,
|
|
27
|
+
opacity: 0.9,
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
const SpeedDialTool: React.FC<SpeedDialToolProps> = ({
|
|
33
|
+
style,
|
|
34
|
+
onSquareClick,
|
|
35
|
+
onCircleClick,
|
|
36
|
+
onCircleSectorClick,
|
|
37
|
+
onCircleSegmentClick
|
|
38
|
+
}) => {
|
|
39
|
+
const mergedStyles = { ...defaultStyles, ...style };
|
|
40
|
+
const backgroundColor = mergedStyles.color;
|
|
41
|
+
|
|
42
|
+
const actions = [
|
|
43
|
+
{
|
|
44
|
+
icon: <SquareIcon />,
|
|
45
|
+
name: 'Square',
|
|
46
|
+
onClick: onSquareClick,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
icon: <SolidCircleIcon sx={{ color: 'inherit' }} />,
|
|
50
|
+
name: 'Circle',
|
|
51
|
+
onClick: onCircleClick,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
icon: <HalfCircleIcon sx={{ color: 'inherit' }} />,
|
|
55
|
+
name: 'Segment',
|
|
56
|
+
onClick: onCircleSegmentClick,
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
icon: <PivotIcon sx={{ color: 'inherit' }} />,
|
|
60
|
+
name: 'Sector',
|
|
61
|
+
onClick: onCircleSectorClick,
|
|
62
|
+
}
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<StyledSpeedDial
|
|
67
|
+
ariaLabel="SpeedDial tool options"
|
|
68
|
+
customcolor={backgroundColor}
|
|
69
|
+
sx={{
|
|
70
|
+
position: mergedStyles.position,
|
|
71
|
+
top: mergedStyles.top,
|
|
72
|
+
bottom: mergedStyles.bottom,
|
|
73
|
+
left: mergedStyles.left,
|
|
74
|
+
right: mergedStyles.right,
|
|
75
|
+
}}
|
|
76
|
+
icon={<SpeedDialIcon sx={{ color: '#ffffff' }} />}
|
|
77
|
+
>
|
|
78
|
+
{actions.map((action) => (
|
|
79
|
+
<SpeedDialAction
|
|
80
|
+
key={action.name}
|
|
81
|
+
icon={action.icon}
|
|
82
|
+
tooltipTitle={action.name}
|
|
83
|
+
onClick={action.onClick}
|
|
84
|
+
sx={{
|
|
85
|
+
backgroundColor: backgroundColor,
|
|
86
|
+
'&:hover': {
|
|
87
|
+
backgroundColor: backgroundColor,
|
|
88
|
+
opacity: 0.9,
|
|
89
|
+
}
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
92
|
+
))}
|
|
93
|
+
</StyledSpeedDial>
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default SpeedDialTool;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Export the component
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
//import AgnifyMapComponent from "./AgnifyMapComponent";
|
|
5
|
+
//export default AgnifyMapComponent;
|
|
6
|
+
|
|
7
|
+
import JPMapComponent from "./JPMapComponent";
|
|
8
|
+
export default JPMapComponent;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
// Export the interfaces
|
|
12
|
+
export type { Field } from "../interfaces/Data/Field";
|
|
13
|
+
export type { NDVI } from "../interfaces/Data/NDVI";
|
|
14
|
+
export type { MapLocationFeature } from "../interfaces/Data/MapLocationFeature";
|
|
15
|
+
export type { Farm } from "../interfaces/Data/Farm";
|
|
16
|
+
export type { CustomMapOptions } from "../interfaces/CustomMapOptions";
|
|
17
|
+
export type { Mode, ModeType } from "../interfaces/Mode";
|
|
18
|
+
export type { Properties, Icon } from "../interfaces/Properties";
|
|
19
|
+
export type { PolygonOptions, Style, Icon as ModeIcon, Properties as ModeProperties } from "../interfaces/Mode";
|
|
20
|
+
export type { Message, MessageType } from '../interfaces/Message';
|
|
21
|
+
export type { EnterpriseRegion } from '../interfaces/Data/EnterpriseRegion';
|
|
22
|
+
export type { MapOverlayManager } from '../js/mapEncapsulation/mapOverlayManager';
|