2015-10-18 04:42:17 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Leaflet debug page</title>
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../css/screen.css" />
|
|
|
|
|
|
|
|
<script type="text/javascript" src="../../build/deps.js"></script>
|
|
|
|
<script src="../leaflet-include.js"></script>
|
|
|
|
<style type="text/css">
|
|
|
|
.my-div-icon {
|
|
|
|
background-color: goldenrod;
|
|
|
|
text-align: center;
|
|
|
|
}
|
2016-05-06 19:30:58 +08:00
|
|
|
#map {
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
2015-10-18 04:42:17 +08:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div id="map"></div>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
var center = [41.2058, 9.4307];
|
|
|
|
|
|
|
|
var map = L.map('map').setView(center, 13);
|
|
|
|
|
|
|
|
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
|
2016-05-06 21:00:01 +08:00
|
|
|
attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
|
2015-10-18 04:42:17 +08:00
|
|
|
}).addTo(map);
|
|
|
|
|
|
|
|
L.polygon([[41.21, 9.42], [41.22, 9.40], [41.23, 9.40]]).addTo(map).bindLabel('Default centered polygon label');
|
2016-05-06 21:00:01 +08:00
|
|
|
L.polygon([[41.20, 9.41], [41.20, 9.39], [41.21, 9.40]]).addTo(map).bindLabel('Polygon label following mouse', {sticky: true});
|
|
|
|
L.polygon([[41.18, 9.42], [41.17, 9.40], [41.19, 9.38]]).addTo(map).bindLabel('Permanent polygon label', {permanent: true});
|
2015-10-18 04:42:17 +08:00
|
|
|
L.marker([41.20, 9.4307]).addTo(map).bindLabel('label on the left', {direction: 'left'});
|
2016-05-06 21:00:01 +08:00
|
|
|
L.marker([41.206, 9.44]).addTo(map).bindLabel('click me, I have a popup', {permanent: true, interactive: true}).bindPopup('See?');
|
|
|
|
L.circleMarker([41.206, 9.48], {color: 'Chocolate', radius: 12}).addTo(map).bindLabel('Hello Left World', {direction: 'left'});
|
|
|
|
L.circleMarker([41.20, 9.50], {color: 'Chocolate', radius: 12}).addTo(map).bindLabel('Hello top World', {direction: 'top', permanent: true});
|
2016-07-02 16:52:04 +08:00
|
|
|
L.circleMarker([41.20, 9.47], {color: 'Tomato', radius: 10}).addTo(map).bindLabel('Seems I am centered', {direction: 'center', permanent: true, interactive: true}).bindPopup('Yeah');
|
|
|
|
L.circleMarker([41.195, 9.47], {color: 'Tomato', radius: 10}).addTo(map).bindLabel('Me too', {direction: 'center'}).bindPopup('Yeah');
|
2015-10-18 04:42:17 +08:00
|
|
|
var icon = L.divIcon({
|
2015-11-16 01:41:46 +08:00
|
|
|
className: 'my-div-icon',
|
|
|
|
html: '<p>A div icon</p>',
|
2016-05-06 21:00:01 +08:00
|
|
|
iconSize: [50, 50]
|
2015-10-18 04:42:17 +08:00
|
|
|
});
|
2016-05-06 21:00:01 +08:00
|
|
|
L.marker([41.22, 9.48], {icon: icon}).addTo(map).bindLabel('A div icon label following mouse', {sticky: true, direction: 'auto'});
|
2015-10-18 04:42:17 +08:00
|
|
|
L.marker([41.23, 9.47], {icon: icon}).addTo(map).bindLabel('A div icon label');
|
2016-05-06 21:00:01 +08:00
|
|
|
L.marker([41.23, 9.42], {draggable: true}).addTo(map).bindLabel('Draggable marker label', {permanent: true, direction: 'auto'});
|
2016-07-02 16:52:04 +08:00
|
|
|
L.marker([41.19, 9.43]).addTo(map).bindLabel('Clickable marker label', {permanent: true, interactive: true}).on('click', function () { alert('clicked!'); });
|
2015-10-18 04:42:17 +08:00
|
|
|
|
2015-11-16 01:41:46 +08:00
|
|
|
var marker1 = L.marker([41.18, 9.45], {description: 'Marker 1'});
|
|
|
|
var marker2 = L.marker([41.18, 9.46], {description: 'Marker 2'});
|
|
|
|
var group = new L.FeatureGroup([marker1, marker2]).addTo(map);
|
|
|
|
group.bindLabel(function (layer) {
|
|
|
|
return 'Group label: ' + layer.options.description;
|
2015-11-16 02:15:14 +08:00
|
|
|
}, {opacity: 0.7});
|
2016-05-06 21:00:01 +08:00
|
|
|
L.marker([41.18, 9.35]).addTo(map).bindLabel('Top label is top', {permanent: true, direction: 'top'});
|
|
|
|
L.marker([41.173, 9.37]).addTo(map).bindLabel('Bottom label is weird but ok', {permanent: true, direction: 'bottom'});
|
|
|
|
L.polyline([[41.20, 9.36], [41.205, 9.35], [41.19, 9.34]]).addTo(map).bindLabel('Polyline label', {permanent: true, direction: 'top'});
|
|
|
|
L.polygon([[41.21, 9.36], [41.24, 9.35], [41.23, 9.34]]).addTo(map).bindLabel('Top label following mouse', {sticky: true, direction: 'top'});
|
2015-11-16 01:41:46 +08:00
|
|
|
|
2015-10-18 04:42:17 +08:00
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|