101 lines
2.9 KiB
HTML
101 lines
2.9 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" />
|
|
<style type="text/css">
|
|
#map {
|
|
width: 500px;
|
|
height: 400px;
|
|
margin-right: 10px;
|
|
}
|
|
#config {
|
|
margin: 10px;
|
|
height: 215px;
|
|
display: block;
|
|
}
|
|
fieldset, label {
|
|
margin: 0 10px;
|
|
max-width: 600px;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<h3><a href="../"><big>◄</big> Leaflet Panel Layers</a></h3>
|
|
<h4> Dynamic Example: build panel dynamically from JSON config</h4>
|
|
<br />
|
|
|
|
<div id="map"></div>
|
|
<label>Select Layer Definitions For Map:</label><br />
|
|
<br />
|
|
<fieldset id="baselayers">
|
|
<legend>baselayers</legend>
|
|
</fieldset>
|
|
<br />
|
|
<fieldset id="overlayers">
|
|
<legend>overlayers</legend>
|
|
</fieldset>
|
|
|
|
<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="https://code.jquery.com/jquery-3.4.1.min.js"
|
|
integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
|
|
crossorigin="anonymous"></script>
|
|
|
|
<script src="../src/leaflet-panel-layers.js"></script>
|
|
<script>
|
|
|
|
$.getJSON('config-layers.json', function(config, status, xhr) {
|
|
|
|
window.map = L.map('map', {
|
|
zoom: 11,
|
|
center: L.latLng([42.4918,12.4992]),
|
|
attributionControl: false,
|
|
maxBounds: L.latLngBounds([[42.41281,12.28821],[42.5589,12.63805]]).pad(0.5)
|
|
});
|
|
|
|
window.config = config;
|
|
window.panel = L.control.panelLayers().addTo(map);
|
|
|
|
$.each(config, function(typeLayer, items) {
|
|
$.each(items, function(i, item) {
|
|
|
|
var $label = $('<label>'+item.name+'</label>')
|
|
.appendTo('#'+typeLayer);
|
|
|
|
$('<input type="checkbox" value="'+item.name+'" />').on('click', function(e) {
|
|
|
|
if( $(e.target).prop('checked') ) {
|
|
|
|
if(typeLayer==='baselayers')
|
|
panel.addBaseLayer(item);
|
|
else if(typeLayer==='overlayers')
|
|
panel.addOverlay(item);
|
|
}
|
|
else
|
|
panel.removeLayer(item);
|
|
|
|
}).prependTo($label);
|
|
});
|
|
});
|
|
|
|
$('#baselayers').find(':checkbox').first().click();
|
|
|
|
|
|
});
|
|
|
|
</script>
|
|
<script type="text/javascript" src="/labs-common.js"></script>
|
|
|
|
</body>
|
|
</html>
|