2013-05-30 21:58:59 +08:00
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Test for preservation of Icon DOM element</title>
|
|
|
|
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
2013-11-08 22:43:14 +08:00
|
|
|
|
2013-05-30 21:58:59 +08:00
|
|
|
<link rel="stylesheet" href="../css/screen.css" />
|
2013-11-08 22:43:14 +08:00
|
|
|
|
2017-02-04 23:17:51 +08:00
|
|
|
<script src="../../build/deps.js"></script>
|
2013-05-30 21:58:59 +08:00
|
|
|
<script src="../leaflet-include.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="map" style="width: 600px; height: 600px; border: 1px solid #ccc"></div>
|
2013-11-08 22:43:14 +08:00
|
|
|
|
2017-02-04 23:17:51 +08:00
|
|
|
<script>
|
2013-11-08 22:43:14 +08:00
|
|
|
|
2013-05-30 21:58:59 +08:00
|
|
|
var blueIcon = new L.Icon({iconUrl: 'http://www.webatlas.no/webatlasapi/v/071009/media/interface/default/markers/flag_blue.gif'});
|
|
|
|
var redIcon = new L.Icon({iconUrl: 'http://www.webatlas.no/webatlasapi/v/071009/media/interface/default/markers/flag_red.gif'});
|
|
|
|
|
|
|
|
var map = L.map('map').setView( [50, 50], 10);
|
|
|
|
|
2013-05-31 20:16:18 +08:00
|
|
|
var marker = L.marker([50, 50], {icon: blueIcon, draggable: true});
|
2013-05-30 21:58:59 +08:00
|
|
|
|
2013-05-31 20:16:18 +08:00
|
|
|
marker.on('dragstart', function () {
|
|
|
|
console.log('dragstart');
|
2013-05-30 21:58:59 +08:00
|
|
|
marker.setIcon(redIcon);
|
|
|
|
//This is the previous workaround:
|
|
|
|
//var iconElem = L.DomUtil.get(marker._icon);
|
|
|
|
//iconElem.src = 'http://www.webatlas.no/webatlasapi/v/071009/media/interface/default/markers/flag_red.gif';
|
|
|
|
});
|
|
|
|
|
2013-05-31 20:16:18 +08:00
|
|
|
marker.on('dragend', function () {
|
|
|
|
console.log('dragend');
|
2013-05-30 21:58:59 +08:00
|
|
|
marker.setIcon(blueIcon);
|
|
|
|
//This is the previous workaround:
|
|
|
|
//var iconElem = L.DomUtil.get(marker._icon);
|
|
|
|
//iconElem.src = 'http://www.webatlas.no/webatlasapi/v/071009/media/interface/default/markers/flag_blue.gif';
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
marker.addTo(map);
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|