Leaflet/debug/tests/click_on_canvas.html

59 lines
1.7 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" />
<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() {
2014-03-04 23:54:41 +08:00
var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
osmAttrib = '&copy; <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib});
2013-02-18 03:17:44 +08:00
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,
2014-03-04 23:54:41 +08:00
layers: [osm]
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',
2014-08-05 23:14:02 +08:00
interactive: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>