UNPKG

mohsen-angular-leaflet-directive

Version:

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

123 lines (115 loc) 4.32 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("MarkersTwoMapsEventsController", ['$scope', 'leafletData', function ($scope, $modalInstance, leafletData) { var markers = []; markers.push({ lat: 52.229676, lng: 21.012229, draggable: false }); markers.push({ lat: 52.219081, lng: 21.025386, draggable: false }); angular.extend($scope, { defaults: { maxZoom: 18, minZoom: 0, scrollWheelZoom: false }, events: { map: { enable: [], logic: 'emit' }, marker: { enable: [ 'click' ], logic: 'emit' } }, layers: { baselayers: { osm: { name: 'OpenStreetMap', type: 'xyz', url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', layerOptions: { subdomains: ['a', 'b', 'c'], attribution: '© OpenStreetMap contributors', continuousWorld: true } } } }, center: { zoom: 13, lat: 52.229676, lng: 21.012229 }, markers: markers }); var markers2 = []; markers2.push({ lat: 52.229676, lng: 21.012229, draggable: false }); markers2.push({ lat: 52.219081, lng: 21.025386, draggable: false }); angular.extend($scope, { defaults2: { maxZoom: 18, minZoom: 0, scrollWheelZoom: false }, events2: { map: { enable: [], logic: 'emit' }, marker: { enable: [ 'click' ], logic: 'emit' } }, layers2: { baselayers: { mapbox: { name: 'Mapbox Terrain', url: 'http://a.tiles.mapbox.com/v3/examples.map-i86nkdio/{z}/{x}/{y}.png', type: 'xyz' } } }, center2: { zoom: 13, lat: 52.229676, lng: 21.012229 }, markers2: markers2 }); $scope.$on('leafletDirectiveMarker.click', function (e, args) { console.log(args); }); }]); </script> </head> <body ng-controller="MarkersTwoMapsEventsController"> <leaflet lf-defaults="defaults" lf-events="events" lf-center="center" lf-markers="markers" lf-layers="layers" id="global-map" width="100%" height="240px"></leaflet> <leaflet lf-defaults="defaults2" lf-events="events2" lf-center="center2" lf-markers="markers2" lf-layers="layers2" id="global-map2" width="100%" height="240px"></leaflet> <h1>Two maps with markers and events</h1> <p>Click on any of the markers to show a popup with a message.</p> </body> </html>