mirror of
https://github.com/Leaflet/Path.Drag.js.git
synced 2025-07-23 02:55:32 +00:00

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
47 lines
1.5 KiB
HTML
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: '© <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>
|