2012-03-03 23:39:18 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
2016-04-29 17:35:50 +08:00
|
|
|
<title>Leaflet debug page</title>
|
2012-03-03 23:39:18 +08:00
|
|
|
|
2016-04-29 17:35:50 +08:00
|
|
|
<link rel="stylesheet" href="../../dist/leaflet.css" />
|
2013-03-22 22:27:07 +08:00
|
|
|
|
2016-04-29 17:35:50 +08:00
|
|
|
<link rel="stylesheet" href="../css/screen.css" />
|
2013-03-22 22:27:07 +08:00
|
|
|
|
2016-04-29 17:35:50 +08:00
|
|
|
<script src="../leaflet-include.js"></script>
|
2012-03-03 23:39:18 +08:00
|
|
|
</head>
|
|
|
|
<body>
|
2016-04-29 17:35:50 +08:00
|
|
|
<div id="map" style="width: 800px; height: 600px; border: 1px solid #ccc"></div>
|
2012-03-03 23:39:18 +08:00
|
|
|
<button onclick="boundsExtendBounds();">Extend the bounds of the center rectangle with the upper right rectangle</button>
|
|
|
|
<button onclick="boundsExtendLatLng()">Extend the bounds of the center rectangle with the lower left marker</button>
|
2016-04-29 17:35:50 +08:00
|
|
|
<script src="route.js"></script>
|
|
|
|
<script>
|
2018-03-12 15:46:20 +08:00
|
|
|
var osmUrl = 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
2016-04-29 17:35:50 +08:00
|
|
|
osm = new L.TileLayer(osmUrl, {maxZoom: 18});
|
2012-03-03 23:39:18 +08:00
|
|
|
|
|
|
|
var latLng = new L.LatLng(54.18815548107151, -7.657470703124999);
|
|
|
|
|
2016-04-29 17:35:50 +08:00
|
|
|
var bounds1 = new L.LatLngBounds(new L.LatLng(54.559322, -5.767822), new L.LatLng(56.1210604, -3.021240));
|
2012-03-03 23:39:18 +08:00
|
|
|
var bounds2 = new L.LatLngBounds(new L.LatLng(56.56023925701561, -2.076416015625), new L.LatLng(57.01158038001565, -0.9777832031250001));
|
|
|
|
var bounds3;
|
|
|
|
|
2016-04-29 17:35:50 +08:00
|
|
|
var map = new L.Map('map', {
|
|
|
|
layers: [osm],
|
|
|
|
center: bounds1.getCenter(),
|
|
|
|
zoom: 7
|
|
|
|
});
|
2012-03-03 23:39:18 +08:00
|
|
|
|
|
|
|
var rectangle1 = new L.Rectangle(bounds1);
|
|
|
|
var rectangle2 = new L.Rectangle(bounds2);
|
|
|
|
var rectangle3;
|
|
|
|
|
|
|
|
var marker = new L.Marker(latLng);
|
|
|
|
|
2016-04-29 17:35:50 +08:00
|
|
|
map.addLayer(rectangle1).addLayer(rectangle2).addLayer(marker);
|
2013-03-22 22:27:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2012-03-03 23:39:18 +08:00
|
|
|
|
|
|
|
function boundsExtendBounds() {
|
2016-04-29 17:35:50 +08:00
|
|
|
if (rectangle3) {
|
|
|
|
map.removeLayer(rectangle3);
|
|
|
|
rectangle3 = null;
|
|
|
|
}
|
|
|
|
if (bounds3) {
|
|
|
|
bounds3 = null;
|
|
|
|
}
|
|
|
|
bounds3 = new L.LatLngBounds(bounds1.getSouthWest(), bounds1.getNorthEast());
|
|
|
|
bounds3.extend(bounds2);
|
|
|
|
rectangle3 = new L.Rectangle(bounds3, {
|
|
|
|
color: "#ff0000",
|
|
|
|
weight: 1,
|
|
|
|
opacity: 1,
|
|
|
|
fillOpacity: 0
|
|
|
|
});
|
|
|
|
|
|
|
|
map.addLayer(rectangle3);
|
2012-03-03 23:39:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function boundsExtendLatLng() {
|
2016-04-29 17:35:50 +08:00
|
|
|
if (rectangle3) {
|
|
|
|
map.removeLayer(rectangle3);
|
|
|
|
rectangle3 = null;
|
|
|
|
}
|
|
|
|
if (bounds3) {
|
|
|
|
bounds3 = null;
|
|
|
|
}
|
|
|
|
bounds3 = new L.LatLngBounds(bounds1.getSouthWest(), bounds1.getNorthEast());
|
|
|
|
bounds3.extend(marker.getLatLng());
|
|
|
|
rectangle3 = new L.Rectangle(bounds3, {
|
|
|
|
color: "#ff0000",
|
|
|
|
weight: 1,
|
|
|
|
opacity: 1,
|
|
|
|
fillOpacity: 0
|
|
|
|
});
|
|
|
|
|
|
|
|
map.addLayer(rectangle3);
|
2012-03-03 23:39:18 +08:00
|
|
|
}
|
2013-03-22 22:27:07 +08:00
|
|
|
|
2016-04-29 17:35:50 +08:00
|
|
|
</script>
|
2012-03-03 23:39:18 +08:00
|
|
|
</body>
|
2013-03-22 22:27:07 +08:00
|
|
|
</html>
|