UNPKG

mohsen-angular-leaflet-directive

Version:

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

42 lines (38 loc) 1.51 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.js"></script> <link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" /> <script> var app = angular.module("demoapp", ["leaflet-directive"]); app.controller('MarkersEventsAddController', [ '$scope', function($scope) { angular.extend($scope, { london: { lat: 51.505, lng: -0.09, zoom: 8 }, events: {} }); $scope.markers = new Array(); $scope.$on("leafletDirectiveMap.click", function(event, args){ var leafEvent = args.leafletEvent; $scope.markers.push({ lat: leafEvent.latlng.lat, lng: leafEvent.latlng.lng, message: "My Added Marker" }); }); } ]); </script> </head> <body ng-controller="MarkersEventsAddController"> <leaflet lf-center="london" lf-markers="markers" lf-events="events" height="480px" width="100%"></leaflet> <h1>Markers with events example</h1> <p>Click on the map to add a marker</p> </leaflet> </body> </html>