File size: 1,167 Bytes
4dc76bd
 
 
 
 
 
a0f098c
 
8b06b31
9e4ae9e
a0f098c
 
 
 
4dc76bd
 
 
 
a0f098c
 
 
 
4dc76bd
 
a0f098c
4dc76bd
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const map = L.map('map').setView([20, 0], 2);

L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  attribution: '© OpenStreetMap contributors'
}).addTo(map);

// Custom robot marker icon
const robotIcon = L.icon({
  iconUrl: 'https://cdn.shopify.com/s/files/1/0767/2040/6877/files/LeRobot.png?v=1745423992', // Change to your preferred robot icon URL
  iconSize: [35, 35],       // size of the icon
  iconAnchor: [20, 40],     // point of the icon which will correspond to marker's location
  popupAnchor: [0, -35]     // point from which the popup should open relative to the iconAnchor
});

fetch('data.json')
  .then(response => response.json())
  .then(data => {
    data.forEach(entry => {
      const lat = parseFloat(entry.latitude || entry.Latitude);
      const lng = parseFloat(entry.longitude || entry.Longitude);
      const name = entry.name || entry.Name || 'Unknown';
      const desc = entry.description || entry.Description || '';

      if (!isNaN(lat) && !isNaN(lng)) {
        L.marker([lat, lng], { icon: robotIcon })
          .addTo(map)
          .bindPopup(`<strong>${name}</strong><br>${desc}`);
      }
    });
  });