Leaflet/debug/tests/click_on_canvas.html

60 lines
1.9 KiB
HTML
Raw Normal View History

2012-12-28 04:37:57 +08:00
<!DOCTYPE html>
<html>
<head>
<title>Leaflet debug page</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="../../dist/leaflet.css" />
<!--[if lte IE 8]><link rel="stylesheet" href="../../dist/leaflet.ie.css" /><![endif]-->
<link rel="stylesheet" href="../css/screen.css" />
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.0.js'></script>
<script>
L_PREFER_CANVAS = true;
$(document).ready(function() {
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
2013-02-18 03:17:44 +08:00
cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade',
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution});
2012-12-28 04:37:57 +08:00
var map = L.map('map', {
minZoom: 1,
maxZoom: 19,
center: [51.505, -0.09],
2013-02-18 03:17:44 +08:00
zoom: 9,
layers: [cloudmade]
2012-12-28 04:37:57 +08:00
});
var polygons = new L.FeatureGroup();
var points = [[51.505, -0.01], [51.505, -0.09], [51.55, -0.09]];
polygons.addLayer(
new L.Polyline(
points, {
2013-02-18 03:17:44 +08:00
weight: 10,
2012-12-28 04:37:57 +08:00
opacity: 1,
smoothFactor: 1,
2013-02-18 03:17:44 +08:00
color: 'red',
clickable:true
2012-12-28 04:37:57 +08:00
}));
polygons.on('click', function(m) {
// m.layer is the clicked polygon here
//m.layer.bindPopup('hello!').openPopup();
console.log(m.layer)
});
polygons.addTo(map);
});
</script>
2013-02-18 03:17:44 +08:00
<script type="text/javascript" src="../../build/deps.js"></script>
2012-12-28 04:37:57 +08:00
<script src="../leaflet-include.js"></script>
</head>
<body>
<div id="map"></div>
</body>
</html>