-
Notifications
You must be signed in to change notification settings - Fork 0
/
carte_find_clustering.html
122 lines (99 loc) · 3.83 KB
/
carte_find_clustering.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<html>
<head>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" integrity="sha256-kLaT2GOSpHechhsozzB+flnD+zUyjE2LlfWPgU04xyI=" crossorigin="" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js" integrity="sha256-WBkoXOwTeyKclOHuWtc+i2uENFpDZ9YPdf5Hf+D7ewM=" crossorigin=""></script>
<script src="http://code.jquery.com/jquery-3.3.1.slim.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.5.3/leaflet.markercluster.js" integrity="sha512-OFs3W4DIZ5ZkrDhBFtsCP6JXtMEDGmhl0QPlmWYBJay40TT1n3gt2Xuw8Pf/iezgW9CdabjkNChRqozl/YADmg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.markercluster/1.5.3/MarkerCluster.Default.css" integrity="sha512-6ZCLMiYwTeli2rVh3XAPxy3YoR5fVxGdH/pz+KMCzRY2M65Emgkw00Yqmhh8qLGeYQ3LbVZGdmOX9KUjSKr0TA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/leaflet-markercluster.placementstrategies.js"></script>
<meta name="viewport" content="width=device-width,
initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style type="text/css">
#map {
position: absolute;
width: 100.0%;
height: 100.0%;
left: 0.0%;
top: 0.0%;
z-index: 1;
}
.leaflet-tooltip {
position: absolute;
padding: 6px;
background-color: #fff;
border: 1px solid #fff;
border-radius: 3px;
color: #222;
white-space: break-spaces;
width: 200px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
pointer-events: none;
box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.leaflet-div-icon2
{
background:#deb400;
font-weight:bold;
text-align:center;
border-radius:50%;
line-height:30px;
}
.image-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: black;
}
</style>
</head>
<body>
<div id="map" ></div>
<script type="text/javascript">
var map = L.map(
"map",
{
center: [-19, -70],
crs: L.CRS.EPSG3857,
zoom: 4,
zoomControl: false,
preferCanvas: false,
}
);
var tile_layer = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
maxZoom: 19
}).addTo(map);
(async function() {
var description = await fetch("https://raw.githubusercontent.com/lisebernard/lisebernard.github.io/main/data/data_map_find.json").then(response => response.json().then(data => description = data))
var longueur = Object.entries(description['Latitude']).length
var clstr = L.markerClusterGroup({disableClusteringAtZoom: 8,
elementsPlacementStrategy: "spiral",
showCoverageOnHover: false,
});
for (let i=0; i<longueur; i++) {
var lat = description['Latitude'][i];
var lng = description['Longitude'][i];
var desc = description['Lieux'][i]
var ID = description['ID'][i]
var img = description['Images'][i]
var image = `https://raw.githubusercontent.com/lisebernard/lisebernard.github.io/main/img_rescaled/comp_${img}`
var marker = L.circleMarker([lat,lng], {radius: 4,
fillColor: "#deb400",
color: "#000",
weight: 1,
opacity: 1,
fillOpacity: 0.8,
});
marker.bindTooltip(`<div> <font size="3" > <b>ID:</b> ${ID} <br>
<img src='${image}' width="100"
height="100"/> </br>
<b> Lieux de découverte: </b> ${desc} </font> </div>`);
marker.addTo(clstr);}
clstr.addTo(map);
})();
</script>
</body>
</html>