Files
path.drag.js/example/index.html
Yohan Boniface a15c06a3d7 Use path center as event.latlng for move event
The move event is listened by popup and tooltip when attached to
a layer, so we want to keep them centered, not to follow the mouse
position while dragging.

fix Leaflet/Leaflet.Editable#140
2017-08-09 09:44:33 +02:00

47 lines
1.5 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Path.Drag.js demo</title>
<link rel="stylesheet" href="https://npmcdn.com/leaflet@1.2.0/dist/leaflet.css" />
<script src="https://npmcdn.com/leaflet@1.2.0/dist/leaflet.js"></script>
<script src="../src/Path.Drag.js"></script>
<style type="text/css">
.my-div-icon {
background-color: goldenrod;
text-align: center;
}
body,
html,
#map {
padding: 0;
margin: 0;
width: 100%;
height: 100%
}
</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', {
attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
L.polygon([[41.21, 9.42], [41.22, 9.40], [41.23, 9.40]], {draggable: true}).bindTooltip('drag me', {permanent: true, direction: 'top'}).addTo(map);
L.polygon([[[41.20, 9.41], [41.20, 9.39], [41.21, 9.41]], [[41.18, 9.42], [41.17, 9.40], [41.19, 9.38]]], {color: 'Tomato',draggable: true}).addTo(map);
L.circleMarker([41.20, 9.50], {color: 'Chocolate', radius: 12, draggable: true}).addTo(map);
L.polyline([[41.20, 9.36], [41.205, 9.35], [41.19, 9.34]], {draggable: true}).addTo(map);
</script>
</body>
</html>