-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmap.html
39 lines (33 loc) · 1.15 KB
/
map.html
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
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html>
<head>
<title>Leaflet Map</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet/dist/leaflet.css" />
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<style>
#map { height: 400px; }
</style>
</head>
<body>
<div id="map"></div>
<script>
// Initialize the map
const map = L.map('map').setView([42.37856108498607, -71.23749529922384], 10); // Centered on New York City
// Add the OpenStreetMap tile layer
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>contributors'
}).addTo(map);
// Define an array of locations
const locations = [
{ lat: 40.7851, lng: -73.9683, title: "Central Park" },
{ lat: 40.6892, lng: -74.0445, title: "Statue of Liberty" },
{ lat: 40.7589, lng: -73.9851, title: "Times Square" }
];
// Add markers for each location
locations.forEach(location => {
L.marker([location.lat, location.lng]).addTo(map)
.bindPopup(location.title); // Add a popup with the title
});
</script>
</body>
</html>