-
Notifications
You must be signed in to change notification settings - Fork 632
/
Copy path0106-basic-maxbounds-example.html
65 lines (62 loc) · 2.73 KB
/
0106-basic-maxbounds-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.min.js"></script>
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
<script>
var app = angular.module("demoapp", ["leaflet-directive"]);
app.controller("BasicMaxBoundsController", [ "$scope", "leafletData", function($scope, leafletData) {
$scope.regions = {
london: {
northEast: {
lat: 51.51280224425956,
lng: -0.11681556701660155
},
southWest: {
lat: 51.50211782162702,
lng: -0.14428138732910156
}
},
lisbon: {
southWest: {
lat: 38.700247900602726,
lng: -9.165430068969727
},
northEast: {
lat: 38.72703673982525,
lng: -9.110498428344725
}
},
warszawa: {
southWest: {
lat: 52.14823737817847,
lng: 20.793685913085934
},
northEast: {
lat: 52.31645452105213,
lng: 21.233139038085938
}
}
};
angular.extend($scope, {
maxbounds: $scope.regions.london
});
} ]);
</script>
</head>
<body ng-controller="BasicMaxBoundsController">
<leaflet maxbounds="maxbounds" width="100%" height="480px"></leaflet>
<h1>Setting MaxBounds in a map</h1>
<p>With <strong>maxbounds</strong> the map visualization is limited to a defined zone. Try to pan on these regions to see how it works.</p>
<form>
<button ng-click="maxbounds=regions.london">London region</button>
<button ng-click="maxbounds=regions.lisbon">Lisbon region</button>
<button ng-click="maxbounds=regions.warszawa">Warszawa region</button>
<button ng-click="maxbounds={}">Unset maxbounds</button>
</form>
<p ng-show="maxbounds.northEast" class="result">Maxbounds: NE(lat: {{ maxbounds.northEast.lat }}, lng: {{ maxbounds.northEast.lng }}) SW(lat: {{ maxbounds.southWest.lat }}, lng: {{ maxbounds.southWest.lng }})</p>
</body>
</html>