107 lines
3.3 KiB
HTML
107 lines
3.3 KiB
HTML
<!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>Leaflet Panel Layers</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/>
|
|
<link rel="stylesheet" href="../src/leaflet-panel-layers.css" />
|
|
<link rel="stylesheet" href="icons.css" />
|
|
<link rel="stylesheet" href="style.css" />
|
|
</head>
|
|
|
|
<body>
|
|
<h3><a href="../"><big>◄</big> Leaflet Panel Layers</a></h3>
|
|
<h4> Points Of Interest Example: list multiple base layers and overlays with Custom icon</h4>
|
|
<br />
|
|
<div id="map"></div>
|
|
|
|
<div id="copy"><a href="https://opengeo.tech/">Labs</a> • <a rel="author" href="https://opengeo.tech/stefano-cudini/">Stefano Cudini</a></div>
|
|
|
|
<a href="https://github.com/stefanocudini/leaflet-panel-layers"><img id="ribbon" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
|
|
|
|
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew==" crossorigin=""></script>
|
|
<script src="../src/leaflet-panel-layers.js"></script>
|
|
<!-- GEOJSON DATA -->
|
|
<script src="data/bar.js"></script>
|
|
<script src="data/fuel.js"></script>
|
|
<script src="data/parking.js"></script>
|
|
<script src="data/drinking_water.js"></script>
|
|
<script>
|
|
|
|
var map = L.map('map', {
|
|
zoom: 11,
|
|
attributionControl: false,
|
|
center: L.latLng([42.4918,12.4992]),
|
|
maxBounds: L.latLngBounds([[42.41281,12.28821],[42.5589,12.63805]]).pad(0.5)
|
|
}),
|
|
osmLayer = new L.TileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png');
|
|
|
|
map.addLayer(osmLayer);
|
|
|
|
function iconByName(name) {
|
|
return '<i class="icon icon-'+name+'"></i>';
|
|
}
|
|
|
|
function featureToMarker(feature, latlng) {
|
|
return L.marker(latlng, {
|
|
icon: L.divIcon({
|
|
className: 'marker-'+feature.properties.amenity,
|
|
html: iconByName(feature.properties.amenity),
|
|
iconUrl: '../images/markers/'+feature.properties.amenity+'.png',
|
|
iconSize: [25, 41],
|
|
iconAnchor: [12, 41],
|
|
popupAnchor: [1, -34],
|
|
shadowSize: [41, 41]
|
|
})
|
|
});
|
|
}
|
|
|
|
var baseLayers = [
|
|
{
|
|
name: "OpenStreetMap",
|
|
layer: osmLayer
|
|
},
|
|
{
|
|
name: "OpenCycleMap",
|
|
layer: L.tileLayer('https://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png')
|
|
},
|
|
{
|
|
name: "Outdoors",
|
|
layer: L.tileLayer('https://{s}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png')
|
|
}
|
|
];
|
|
|
|
var overLayers = [
|
|
{
|
|
name: "Bar",
|
|
icon: iconByName('bar'),
|
|
layer: L.geoJson(Bar, {pointToLayer: featureToMarker })
|
|
},
|
|
{
|
|
name: "Drinking Water",
|
|
icon: iconByName('drinking_water'),
|
|
layer: L.geoJson(Drinking_water, {pointToLayer: featureToMarker })
|
|
},
|
|
{
|
|
name: "Fuel",
|
|
icon: iconByName('fuel'),
|
|
layer: L.geoJson(Fuel, {pointToLayer: featureToMarker })
|
|
},
|
|
{
|
|
name: "Parking",
|
|
icon: iconByName('parking'),
|
|
layer: L.geoJson(Parking, {pointToLayer: featureToMarker })
|
|
}
|
|
];
|
|
|
|
var panelLayers = new L.Control.PanelLayers(baseLayers, overLayers);
|
|
|
|
map.addControl(panelLayers);
|
|
|
|
</script>
|
|
|
|
<script type="text/javascript" src="/labs-common.js"></script>
|
|
|
|
</body>
|
|
</html>
|