@vidro/map-handler 1.2.179 → 1.2.191
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 +4 -1
- package/dist/map-handler.js +1 -1
- package/examples/full/apidemo.js +46 -43
- package/examples/full/cachedToken.dat +1 -1
- package/examples/full/cachedTokenData.dat +1 -1
- package/examples/full/docker/Docker_compose.yml +14 -0
- package/examples/full/docker/Dockerfile +27 -0
- package/examples/full/index.php +6 -4
- package/examples/full/tester.css +74 -0
- package/examples/full/tester.js +11 -4
- package/examples/react-next/README.md +260 -18
- package/examples/react-next/components/AuthComponent.js +88 -0
- package/examples/react-next/components/MapButtons.js +151 -30
- package/examples/react-next/components/MapFilters.js +120 -0
- package/examples/react-next/components/MapInfo.js +36 -0
- package/examples/react-next/components/MapLayers.js +60 -0
- package/examples/react-next/components/MapList.js +43 -0
- package/examples/react-next/contexts/auth.js +3 -1
- package/examples/react-next/contexts/maps.js +35 -16
- package/examples/react-next/contexts/messages.js +1 -6
- package/examples/react-next/env.sample +3 -0
- package/examples/react-next/hooks/useMapEvents.js +41 -132
- package/examples/react-next/package.json +2 -2
- package/examples/react-next/pages/index.js +26 -16
- package/examples/react-next/public/discord.svg +8 -0
- package/examples/react-next/public/favicon.ico +0 -0
- package/examples/react-next/public/logo.png +0 -0
- package/package.json +1 -1
- package/src/index.js +8 -3
- package/examples/react-next/components/SessionComponent.js +0 -136
- package/examples/react-next/pages/_document.js +0 -13
- package/examples/react-next/public/globe.svg +0 -1
- package/examples/react-next/public/vercel.svg +0 -1
- package/examples/react-next/public/window.svg +0 -1
- package/examples/react-next/shared/maps-service.js +0 -65
package/src/index.js
CHANGED
@@ -505,10 +505,11 @@ class Communicator extends EventEmitter {
|
|
505
505
|
});
|
506
506
|
};
|
507
507
|
|
508
|
-
Geolocalize = (toggle) => {
|
508
|
+
Geolocalize = (toggle, options) => {
|
509
509
|
this.com.sendMessageToMap({
|
510
510
|
type: "Geolocalize",
|
511
511
|
toggle: toggle,
|
512
|
+
options: options,
|
512
513
|
sessionToken: this.sessionToken,
|
513
514
|
});
|
514
515
|
};
|
@@ -516,7 +517,7 @@ class Communicator extends EventEmitter {
|
|
516
517
|
/* deprecated since v1.1.19 */
|
517
518
|
toggleGiswaterTiled = (toggle, tiled) => {
|
518
519
|
this.com.sendMessageToMap({
|
519
|
-
type: "
|
520
|
+
type: "toggleTiled",
|
520
521
|
toggle: toggle,
|
521
522
|
tiled: tiled,
|
522
523
|
sessionToken: this.sessionToken,
|
@@ -578,9 +579,13 @@ class Communicator extends EventEmitter {
|
|
578
579
|
}
|
579
580
|
};
|
580
581
|
|
581
|
-
clearGeoJSON = () => {
|
582
|
+
clearGeoJSON = (name) => {
|
583
|
+
if (!name) {
|
584
|
+
this.emit("error", { type: "error", error: "No geoJSON layer name" });
|
585
|
+
}
|
582
586
|
return this.com.sendMessageToMap({
|
583
587
|
type: "clearGeoJSON",
|
588
|
+
name: name,
|
584
589
|
sessionToken: this.sessionToken,
|
585
590
|
});
|
586
591
|
};
|
@@ -1,136 +0,0 @@
|
|
1
|
-
import { useAuth } from "@/contexts/auth";
|
2
|
-
import { useMaps } from "@/contexts/maps";
|
3
|
-
import { useMessages } from "@/contexts/messages";
|
4
|
-
import { useEffect, useState } from "react";
|
5
|
-
|
6
|
-
const SessionComponent = () => {
|
7
|
-
const { sessionToken, setSessionToken, mapInfo, mapId, GetMap } = useMaps();
|
8
|
-
const { start } = useMessages();
|
9
|
-
const { apiUrl, setApiUrl, login, logged, logout, projects } = useAuth();
|
10
|
-
const [user, setUser] = useState("test@aiguesmataro.cat");
|
11
|
-
const [pwd, setPwd] = useState("test.12345");
|
12
|
-
const [selectedMap, setSelectedMap] = useState("-1");
|
13
|
-
// Handler for textarea changes
|
14
|
-
const handleTextChange = (event) => {
|
15
|
-
setText(event.target.value);
|
16
|
-
};
|
17
|
-
|
18
|
-
// Handler for API URL input changes
|
19
|
-
const handleApiUrlChange = (event) => {
|
20
|
-
setApiUrl(event.target.value);
|
21
|
-
};
|
22
|
-
|
23
|
-
// Handler for the button click
|
24
|
-
const handleButtonClick = () => {
|
25
|
-
console.log("API URL:", apiUrl);
|
26
|
-
start();
|
27
|
-
};
|
28
|
-
|
29
|
-
useEffect(() => {
|
30
|
-
setSessionToken(
|
31
|
-
"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiIwNjdhODM3NzQwOGI5NjdlNWZkZjFlYmZiMGRiMjNiNDA3NzY1ZjQ1IiwiZGF0YSI6eyJ6b29tIjoyLCJwcmV2aWV3IjpmYWxzZSwiYXBpIjoiaHR0cHM6XC9cL2JtYXBzZGV2LmFpZ3Vlc21hdGFyby5jb21cL2FwaVwvIiwidG9rZW4iOiJkMDc1N2JmNjAxMDc1ZDA0MWE5Y2JjYTJjOWQ3NWU2OSIsInNob3dfbGF5ZXJzIjpbXSwiaWQiOjUwOSwibG9nbyI6Imh0dHBzOlwvXC9ibWFwc2Rldi5haWd1ZXNtYXRhcm8uY29tXC9iYWNrb2ZmaWNlbmV3XC9fbmV4dFwvaW1hZ2U_dXJsPSUyRmJhY2tvZmZpY2VuZXclMkZsb2dvYW1zYS5wbmcmdz05NiZxPTc1IiwiZGVidWciOmZhbHNlLCJ2ZXJib3NlIjpmYWxzZX0sImV4cCI6NDg3NzY1OTI2Mn0.iq7ldyzhiy2iZv76pflmKwRbgj2h00b8vP6ooJRlUUB_ZFAkNNJ2D-wDL0lZBepj_I4NvnKFHymgZp9OMcncqYQvEmu_0FrL81v_L6Hnc81E1avQZN9O64o5asxKtszgfpANIKJIiNsagB6uk5hPS-e5hB6W26eYaAayQUQqbOYr1OgaCQa7opfAk0746Z5DxyXhy0TtbrHjJS7ObG2gHzxRjwp4gJHdBBJMbjGpo365_zcS1tGTCShRsu7xyr-QakVxJkXUl13OLyFluHSPDcAM9CQG_4XSSudn82Ot_Bg6PG1cd7V6cp-rXr7qXScv9y63YxIfhFP1oc9pA2t6-lEt94GhhPBAbZxfN7mMecFYoLWYbPjpAWmIYIHhySY0EdwYiHOVnpL5fg318OzNkqihpDejBwSwRDzNjmQVv83i1culB2vJx3rxQ8xs7wfqBCgRUlmW_gfFeDwPHRXP1fGGeX8VYMGy5XZt4ozyBETKIYUxqQJ10Lro8TUKS-Us1tUrn8Z7-NNp7zKse3bMl70lMPgbRRLvWfaJC9QPXSvhHayDGVEDAUnCW5PiervD5o1d5I_4AfxCfRXdNdRKcvjSdPNoSnbk3D_qrjQm0Uz9_pgGgl8HIUKr3fsCNTAzcbUtkM3C_nfXOeHAD-IOacTnc6O3kriso-CVKcCF_CE"
|
32
|
-
);
|
33
|
-
setApiUrl("https://bmapsdev.aiguesmataro.com/api/");
|
34
|
-
}, []);
|
35
|
-
|
36
|
-
useEffect(() => {
|
37
|
-
if (!mapInfo) return;
|
38
|
-
GetMap(mapId); //starts mapComponent
|
39
|
-
}, [mapInfo, mapId]);
|
40
|
-
|
41
|
-
return (
|
42
|
-
<div>
|
43
|
-
{logged && (
|
44
|
-
<div className="bg-gray-200 p-2 text-left">
|
45
|
-
<div className="text-xs">
|
46
|
-
Logged as <b>{user}</b>
|
47
|
-
</div>
|
48
|
-
<div className="text-xs">
|
49
|
-
API: <b>{apiUrl}</b>
|
50
|
-
</div>
|
51
|
-
<button
|
52
|
-
onClick={(e) => {
|
53
|
-
logout();
|
54
|
-
}}
|
55
|
-
className="border border-gray-300 bg-black text-white rounded-md p-2 mt-1 text-xs"
|
56
|
-
>
|
57
|
-
Logout
|
58
|
-
</button>
|
59
|
-
<div className="mt-2">
|
60
|
-
<label className="block text-sm font-medium text-gray-700">
|
61
|
-
Maps
|
62
|
-
</label>
|
63
|
-
<select
|
64
|
-
className="border border-gray-300 rounded-md p-2 w-full"
|
65
|
-
onChange={(e) => setSelectedMap(e.target.value)}
|
66
|
-
value={selectedMap}
|
67
|
-
>
|
68
|
-
<option value="-1">Select a map</option>
|
69
|
-
{projects.map((projectId) => (
|
70
|
-
<option key={projectId} value={projectId}>
|
71
|
-
{projectId}
|
72
|
-
</option>
|
73
|
-
))}
|
74
|
-
</select>
|
75
|
-
</div>
|
76
|
-
<button
|
77
|
-
onClick={(e) => {
|
78
|
-
GetMap(selectedMap);
|
79
|
-
}}
|
80
|
-
disabled={selectedMap === "-1"}
|
81
|
-
className="border border-gray-300 bg-black text-white rounded-md p-2 mt-1 text-xs"
|
82
|
-
>
|
83
|
-
Load map
|
84
|
-
</button>
|
85
|
-
</div>
|
86
|
-
)}
|
87
|
-
{!logged && (
|
88
|
-
<div>
|
89
|
-
<div className="mb-4 flex gap-1">
|
90
|
-
<label className="w-32">API URL</label>
|
91
|
-
<input
|
92
|
-
type="text"
|
93
|
-
value={apiUrl}
|
94
|
-
onChange={handleApiUrlChange}
|
95
|
-
placeholder="Enter API URL..."
|
96
|
-
className="border border-gray-300 rounded-md p-2 w-full"
|
97
|
-
/>
|
98
|
-
</div>
|
99
|
-
<div className="mb-4 flex gap-1">
|
100
|
-
<label className="w-32">User</label>
|
101
|
-
<input
|
102
|
-
type="text"
|
103
|
-
value={user}
|
104
|
-
onChange={(e) => setUser(e.target.value)}
|
105
|
-
placeholder="User"
|
106
|
-
disabled={logged}
|
107
|
-
className="border border-gray-300 rounded-md p-2 w-full"
|
108
|
-
/>
|
109
|
-
</div>
|
110
|
-
<div className="mb-4 flex gap-1">
|
111
|
-
<label className="w-32">Password</label>
|
112
|
-
<input
|
113
|
-
type="password"
|
114
|
-
value={pwd}
|
115
|
-
onChange={(e) => setPwd(e.target.value)}
|
116
|
-
disabled={logged}
|
117
|
-
placeholder="User"
|
118
|
-
className="border border-gray-300 rounded-md p-2 w-full"
|
119
|
-
/>
|
120
|
-
</div>
|
121
|
-
|
122
|
-
<button
|
123
|
-
onClick={(e) => {
|
124
|
-
login(user, pwd);
|
125
|
-
}}
|
126
|
-
className="border border-gray-300 bg-black text-white rounded-md p-2"
|
127
|
-
>
|
128
|
-
Login
|
129
|
-
</button>
|
130
|
-
</div>
|
131
|
-
)}
|
132
|
-
</div>
|
133
|
-
);
|
134
|
-
};
|
135
|
-
|
136
|
-
export default SessionComponent;
|
@@ -1 +0,0 @@
|
|
1
|
-
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g clip-path="url(#a)"><path fill-rule="evenodd" clip-rule="evenodd" d="M10.27 14.1a6.5 6.5 0 0 0 3.67-3.45q-1.24.21-2.7.34-.31 1.83-.97 3.1M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m.48-1.52a7 7 0 0 1-.96 0H7.5a4 4 0 0 1-.84-1.32q-.38-.89-.63-2.08a40 40 0 0 0 3.92 0q-.25 1.2-.63 2.08a4 4 0 0 1-.84 1.31zm2.94-4.76q1.66-.15 2.95-.43a7 7 0 0 0 0-2.58q-1.3-.27-2.95-.43a18 18 0 0 1 0 3.44m-1.27-3.54a17 17 0 0 1 0 3.64 39 39 0 0 1-4.3 0 17 17 0 0 1 0-3.64 39 39 0 0 1 4.3 0m1.1-1.17q1.45.13 2.69.34a6.5 6.5 0 0 0-3.67-3.44q.65 1.26.98 3.1M8.48 1.5l.01.02q.41.37.84 1.31.38.89.63 2.08a40 40 0 0 0-3.92 0q.25-1.2.63-2.08a4 4 0 0 1 .85-1.32 7 7 0 0 1 .96 0m-2.75.4a6.5 6.5 0 0 0-3.67 3.44 29 29 0 0 1 2.7-.34q.31-1.83.97-3.1M4.58 6.28q-1.66.16-2.95.43a7 7 0 0 0 0 2.58q1.3.27 2.95.43a18 18 0 0 1 0-3.44m.17 4.71q-1.45-.12-2.69-.34a6.5 6.5 0 0 0 3.67 3.44q-.65-1.27-.98-3.1" fill="#666"/></g><defs><clipPath id="a"><path fill="#fff" d="M0 0h16v16H0z"/></clipPath></defs></svg>
|
@@ -1 +0,0 @@
|
|
1
|
-
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1155 1000"><path d="m577.3 0 577.4 1000H0z" fill="#fff"/></svg>
|
@@ -1 +0,0 @@
|
|
1
|
-
<svg fill="none" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M1.5 2.5h13v10a1 1 0 0 1-1 1h-11a1 1 0 0 1-1-1zM0 1h16v11.5a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 0 12.5zm3.75 4.5a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5M7 4.75a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0m1.75.75a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5" fill="#666"/></svg>
|
@@ -1,65 +0,0 @@
|
|
1
|
-
// Helper function to handle fetch responses
|
2
|
-
const handleResponse = async (response) => {
|
3
|
-
if (!response.ok) {
|
4
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
5
|
-
}
|
6
|
-
return response.json();
|
7
|
-
};
|
8
|
-
|
9
|
-
/*** Get map */
|
10
|
-
const getMap = async (id) => {
|
11
|
-
let url = `map/${id}`;
|
12
|
-
|
13
|
-
try {
|
14
|
-
const response = await fetch(url, {
|
15
|
-
method: "GET",
|
16
|
-
headers: {
|
17
|
-
"Content-Type": "application/json",
|
18
|
-
},
|
19
|
-
});
|
20
|
-
return handleResponse(response);
|
21
|
-
} catch (error) {
|
22
|
-
console.error("Error fetching map:", error);
|
23
|
-
throw error;
|
24
|
-
}
|
25
|
-
};
|
26
|
-
|
27
|
-
/*** Get map info */
|
28
|
-
const getMapInfo = async (id) => {
|
29
|
-
try {
|
30
|
-
const response = await fetch(`map/detail/${id}`, {
|
31
|
-
method: "GET",
|
32
|
-
headers: {
|
33
|
-
"Content-Type": "application/json",
|
34
|
-
},
|
35
|
-
});
|
36
|
-
return handleResponse(response);
|
37
|
-
} catch (error) {
|
38
|
-
console.error("Error fetching map info:", error);
|
39
|
-
throw error;
|
40
|
-
}
|
41
|
-
};
|
42
|
-
|
43
|
-
/*** Get map toc */
|
44
|
-
const getMapToc = async (id) => {
|
45
|
-
try {
|
46
|
-
const response = await fetch(`map/toc/${id}`, {
|
47
|
-
method: "GET",
|
48
|
-
headers: {
|
49
|
-
"Content-Type": "application/json",
|
50
|
-
},
|
51
|
-
});
|
52
|
-
return handleResponse(response);
|
53
|
-
} catch (error) {
|
54
|
-
console.error("Error fetching map TOC:", error);
|
55
|
-
throw error;
|
56
|
-
}
|
57
|
-
};
|
58
|
-
|
59
|
-
const MapService = {
|
60
|
-
getMap,
|
61
|
-
getMapInfo,
|
62
|
-
getMapToc,
|
63
|
-
};
|
64
|
-
|
65
|
-
export default MapService;
|