Update script.js
Browse files
script.js
CHANGED
@@ -4,17 +4,25 @@ L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
|
4 |
attribution: '© OpenStreetMap contributors'
|
5 |
}).addTo(map);
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
fetch('data.json')
|
8 |
.then(response => response.json())
|
9 |
.then(data => {
|
10 |
data.forEach(entry => {
|
11 |
-
const lat = parseFloat(entry.latitude);
|
12 |
-
const lng = parseFloat(entry.longitude);
|
13 |
-
const name = entry.name || 'Unknown';
|
14 |
-
const desc = entry.description || '';
|
15 |
|
16 |
if (!isNaN(lat) && !isNaN(lng)) {
|
17 |
-
L.marker([lat, lng])
|
18 |
.addTo(map)
|
19 |
.bindPopup(`<strong>${name}</strong><br>${desc}`);
|
20 |
}
|
|
|
4 |
attribution: '© OpenStreetMap contributors'
|
5 |
}).addTo(map);
|
6 |
|
7 |
+
// Custom robot marker icon
|
8 |
+
const robotIcon = L.icon({
|
9 |
+
iconUrl: 'https://cdn-icons-png.flaticon.com/512/4712/4712074.png', // Change to your preferred robot icon URL
|
10 |
+
iconSize: [40, 40], // 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 |
}
|