UNPKG

mohsen-angular-leaflet-directive

Version:

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

44 lines (42 loc) 1.75 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("BasicAccessLeafletObjectController", [ "$scope", "leafletLogger", "leafletData", function($scope, leafletLogger, leafletData) { angular.extend($scope, { london: { lat: 51.505, lng: -0.09, zoom: 4 } }); $scope.fitBounds = function() { leafletData.getMap().then(function(map) { map.fitBounds([ [40.712, -74.227], [40.774, -74.125] ]); }); }; }]); </script> <style> input { width: 120px; margin-right: 10px; } </style> </head> <body ng-controller="BasicAccessLeafletObjectController"> <leaflet lf-center="london" width="100%" height="480px"></leaflet> <h1>Direct access to the Leaflet Map Object</h1> <p><button ng-click="fitBounds()">Fitbounds outside leaflet-directive!</button></p> <form> <p>Latitude : <input type="number" step="any" ng-model="london.lat" /> Longitude : <input type="number" step="any" ng-model="london.lng" /></p> <p>Zoom : <input type="number" step="any" ng-model="london.zoom" /></p> </form> </body> </html>