UNPKG

mohsen-angular-leaflet-directive

Version:

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

70 lines (65 loc) 2.56 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("BasicDoubleMapSharingAttributesController", [ "$scope", "leafletLogger", "$http", "leafletData", function($scope, leafletLogger, $http, leafletData) { angular.extend($scope, { center: { lat: 43.7350, lng: -79.3734, zoom: 11 }, defaults: { scrollWheelZoom: false }, markers1: { one: { lat: 43.75, lng: -79.56 }, two: { lat: 43.76, lng: -79.50 } }, markers2: { one: { lat: 43.75, lng: -79.56 }, two: { lat: 43.75, lng: -79.45 }, three: { lat: 43.81, lng: -79.26 } } }); $http.get('json/toronto1.json').success(function(data, status) { $scope.toronto1 = data; }); $http.get('json/toronto2.json').success(function(data, status) { $scope.toronto2 = data; }); }]); </script> </head> <body ng-controller="BasicDoubleMapSharingAttributesController"> <div style="float: left; width: 50%;"> <leaflet id="map1" lf-geojson="toronto1" lf-defaults="defaults" lf-markers="markers1" lf-center="center" width="100%" height="320px"></leaflet> </div> <div style="float: left; width: 50%;"> <leaflet id="map2" lf-geojson="toronto2" lf-defaults="defaults" lf-markers="markers2" lf-center="center" width="100%" height="320px"></leaflet> </div> <h1>Two maps sharing center example</h1> <p>Drag the center in any of the maps</p> </body> </html>