maringetxway commited on
Commit
34cc09a
·
verified ·
1 Parent(s): d696921

Update script.js

Browse files
Files changed (1) hide show
  1. script.js +44 -16
script.js CHANGED
@@ -6,25 +6,53 @@ L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
6
 
7
  // Custom robot marker icon
8
  const robotIcon = L.icon({
9
- iconUrl: 'https://cdn.shopify.com/s/files/1/0767/2040/6877/files/LeRobot.png?v=1745423992', // Change to your preferred robot icon URL
10
- iconSize: [35, 35], // size of the icon
11
- iconAnchor: [20, 40], // point of the icon which will correspond to marker's location
12
- popupAnchor: [0, -35] // point from which the popup should open relative to the iconAnchor
13
  });
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  fetch('data.json')
16
  .then(response => response.json())
17
  .then(data => {
18
- data.forEach(entry => {
19
- const lat = parseFloat(entry.latitude || entry.Latitude);
20
- const lng = parseFloat(entry.longitude || entry.Longitude);
21
- const name = entry.name || entry.Name || 'Unknown';
22
- const desc = entry.description || entry.Description || '';
23
-
24
- if (!isNaN(lat) && !isNaN(lng)) {
25
- L.marker([lat, lng], { icon: robotIcon })
26
- .addTo(map)
27
- .bindPopup(`<strong>${name}</strong><br>${desc}`);
28
- }
29
- });
30
  });
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
  // Custom robot marker icon
8
  const robotIcon = L.icon({
9
+ iconUrl: 'https://cdn.shopify.com/s/files/1/0767/2040/6877/files/LeRobot.png?v=1745423992',
10
+ iconSize: [35, 35],
11
+ iconAnchor: [20, 40],
12
+ popupAnchor: [0, -35]
13
  });
14
 
15
+ // Custom HQ marker icon
16
+ const hqIcon = L.icon({
17
+ iconUrl: 'https://cdn.shopify.com/s/files/1/0767/2040/6877/files/HF_Logo.png?v=1745427981',
18
+ iconSize: [35, 35],
19
+ iconAnchor: [20, 40],
20
+ popupAnchor: [0, -35]
21
+ });
22
+
23
+ // Function to add markers from a dataset
24
+ function addMarkers(data, icon) {
25
+ data.forEach(entry => {
26
+ const lat = parseFloat(entry.latitude || entry.Latitude);
27
+ const lng = parseFloat(entry.longitude || entry.Longitude);
28
+ const name = entry.name || entry.Name || 'Unknown';
29
+ const desc = entry.description || entry.Description || '';
30
+
31
+ if (!isNaN(lat) && !isNaN(lng)) {
32
+ L.marker([lat, lng], { icon: icon })
33
+ .addTo(map)
34
+ .bindPopup(`<strong>${name}</strong><br>${desc}`);
35
+ }
36
+ });
37
+ }
38
+
39
+ // Fetch and process the first dataset
40
  fetch('data.json')
41
  .then(response => response.json())
42
  .then(data => {
43
+ addMarkers(data, robotIcon);
44
+ })
45
+ .catch(error => {
46
+ console.error('Error fetching data.json:', error);
 
 
 
 
 
 
 
 
47
  });
48
+
49
+ // Fetch and process the second dataset
50
+ fetch('data_HQ_HF.json')
51
+ .then(response => response.json())
52
+ .then(data => {
53
+ addMarkers(data, hqIcon);
54
+ })
55
+ .catch(error => {
56
+ console.error('Error fetching data_HQ_HF.json:', error);
57
+ });
58
+