-
Notifications
You must be signed in to change notification settings - Fork 632
/
Copy path0112-basic-maxbounds-pad-example.html
65 lines (59 loc) · 2.46 KB
/
0112-basic-maxbounds-pad-example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html ng-app="demoapp">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../bower_components/angular/angular.min.js"></script>
<script src="../bower_components/leaflet/dist/leaflet.js"></script><script src="../bower_components/angular-simple-logger/dist/index.js"></script>
<script src="../dist/angular-leaflet-directive.js"></script>
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
<script>
var app = angular.module("demoapp", ["leaflet-directive"]);
app.controller("BasicMaxBoundsPadController", ["$scope", "leafletBoundsHelpers", function($scope, leafletBoundsHelpers) {
var maxbounds = leafletBoundsHelpers.createBoundsFromArray([
[37.8866, -79.4877],
[39.7230, -74.9863]
]);
maxbounds.pad = 1.0;
angular.extend($scope, {
bounds: maxbounds,
center: {
lat: 37.8866,
lng: -79-4877,
zoom: 4
},
layers: {
baselayers: {
xyz: {
name: 'OpenStreetMap (XYZ)',
url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
type: 'xyz'
}
},
overlays: {}
},
markers: {
northeast: {
lat: 39.7230,
lng: -74.9863,
focus: true,
title: "Northeast",
},
southwest: {
lat: 37.8866,
lng: -79.4877,
title: "Southwest",
}
},
maxbounds: maxbounds
});
}]);
</script>
</head>
<body ng-controller="BasicMaxBoundsPadController">
<leaflet center="center" layers="layers" markers="markers" maxbounds="maxbounds" width="100%" height="480px"></leaflet>
<h1>Extend Maxbounds with Pad</h1>
<p>You can extend maxbounds with a pad property. <a href=http://leafletjs.com/reference.html#latlngbounds-pad>Pad</a> is a percentage by which the latLngBounds will be extended.</p>
<pre ng-bind="maxbounds | json"></pre>
<pre ng-bind="markers | json"></pre>
</body>
</html>