-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple-collapsed.html
61 lines (46 loc) · 2.07 KB
/
simple-collapsed.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="//unpkg.com/[email protected]/dist/leaflet.css" />
<link rel="stylesheet" href="../dist/leaflet-list-markers.min.css" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h3><a href="../"><big>◄</big> Leaflet List Markers</a></h3>
<h4>Simple Example: <em>Center random italy citi and show visible markers</em></h4>
<div id="map"></div>
<script src="//unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="../dist/leaflet-list-markers.min.js"></script>
<script src="cities-italy.js"></script>
<script>
var map = new L.Map('map', {zoom: 10, minZoom:10, center: L.latLng(43.90974,10.2419) }); //set center from first location
map.addLayer(new L.TileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png')); //base layer
var markersLayer = new L.LayerGroup(); //layer contain searched elements
map.addLayer(markersLayer);
////////////populate map from cities-italy.js
for(var i in cities)
L.marker(L.latLng(cities[i].loc), {title: cities[i].name}).addTo( markersLayer );
//TODO make example using label option with pop fields
//inizialize Leaflet List Markers
var list = new L.Control.ListMarkers({layer: markersLayer, collapsed: true, itemIcon: null});
list.on('item-mouseover', function(e) {
e.layer.setIcon(L.icon({
iconUrl: '../images/select-marker.png'
}))
}).on('item-mouseout', function(e) {
e.layer.setIcon(L.icon({
iconUrl: L.Icon.Default.imagePath+'/marker-icon.png'
}))
}).on("item-click", function(e) {
if(map.options.maxZoom)
map.setView(e.layer.getLatLng(), Math.min(map.getZoom(), map.options.maxZoom) );
else
map.panTo(e.layer.getLatLng());
});
map.addControl( list );
</script>
<div id="copy"><a href="https://opengeo.tech/">Opengeo.tech</a> • <a rel="author" href="https://opengeo.tech/stefano-cudini/">Stefano Cudini</a></div>
</body>
</html>