2012-02-17 14:36:46 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>Leaflet debug page</title>
|
|
|
|
|
|
|
|
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
2013-03-22 22:27:07 +08:00
|
|
|
|
2013-01-31 18:29:39 +08:00
|
|
|
<script type="text/javascript" src="../../build/deps.js"></script>
|
2012-02-17 14:36:46 +08:00
|
|
|
<script src="../leaflet-include.js"></script>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div id="map" style="width: 500px; height: 500px;"></div>
|
2012-02-21 13:08:28 +08:00
|
|
|
<input type="button" value="Set blue rectangle bounds as current map extent." onclick="resetBounds();" />
|
2012-02-17 14:36:46 +08:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
2013-03-22 22:27:07 +08:00
|
|
|
var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/d4fc77ea4a63471cab2423e66626cbb6/997/256/{z}/{x}/{y}.png',
|
2012-02-17 14:36:46 +08:00
|
|
|
cloudmadeAttribution = 'Map data © 2011 OpenStreetMap contributors, Imagery © 2011 CloudMade',
|
|
|
|
cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution});;
|
2013-03-22 22:27:07 +08:00
|
|
|
|
2012-02-17 14:36:46 +08:00
|
|
|
var bounds = new L.LatLngBounds(new L.LatLng(54.559322, -5.767822), new L.LatLng(56.1210604, -3.021240));
|
|
|
|
var bounds2 = new L.LatLngBounds(new L.LatLng(56.2124322195806, -3.427734375), new L.LatLng(56.307776937156945, -3.2560729980468746));
|
|
|
|
|
|
|
|
var rectangle = new L.Rectangle(bounds);
|
|
|
|
var styledRectangle = new L.Rectangle(bounds2, {
|
|
|
|
fillColor: "#ff7800",
|
|
|
|
color: "#000000",
|
|
|
|
opacity: 1,
|
|
|
|
weight: 2
|
|
|
|
});
|
|
|
|
|
|
|
|
rectangle.on("click", function () {
|
|
|
|
alert("you clicked a rectangle.")
|
|
|
|
});
|
2013-03-22 22:27:07 +08:00
|
|
|
|
2012-02-17 14:36:46 +08:00
|
|
|
var map = new L.Map('map', {
|
|
|
|
center: bounds.getCenter(),
|
|
|
|
zoom: 7,
|
|
|
|
layers: [cloudmade]
|
|
|
|
});
|
|
|
|
|
|
|
|
map.addLayer(rectangle).addLayer(styledRectangle);
|
|
|
|
|
2012-02-21 13:08:28 +08:00
|
|
|
function resetBounds() {
|
|
|
|
rectangle.setBounds(map.getBounds());
|
|
|
|
}
|
|
|
|
|
2012-02-17 14:36:46 +08:00
|
|
|
</script>
|
|
|
|
</body>
|
2013-03-22 22:27:07 +08:00
|
|
|
</html>
|