UNPKG

mohsen-angular-leaflet-directive

Version:

angular-leaflet-directive - An AngularJS directive to easily interact with Leaflet maps

66 lines (62 loc) 2.71 kB
<!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="../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 lf-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>