mohsen-angular-leaflet-directive
Version:
angular-leaflet-directive - An AngularJS directive to easily interact with Leaflet maps
76 lines (72 loc) • 2.89 kB
HTML
<html ng-app="demoapp">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="../bower_components/angular/angular.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" />
<style media="screen" type="text/css">
.form-popup {
width: 200px;
}
</style>
<script>
var app = angular.module("demoapp", ["leaflet-directive"]);
app.controller('MarkersAngularTemplateController', [ '$scope', function($scope) {
angular.extend($scope, {
london: {
lat: 51.505,
lng: -0.09,
zoom: 8
},
data: {markers: {}}
});
$scope.addMarkers = function() {
$scope.data.markers = {};
angular.extend($scope.data, { angularInterpolatedMessage : "Angular interpolated message!"});
angular.extend($scope.data, {
markers: {
m1: {
lat: 51.505,
lng: -0.09,
compileMessage: false,
message: "I'm a static marker",
},
m2: {
lat: 51,
lng: 0,
focus: true,
message: "<div ng-include src=\"'views/template.html'\"></div>",
draggable: true,
},
m3: {
lat: 51,
lng: -1,
getMessageScope: function () { return $scope; },
message: "<p>{{data.angularInterpolatedMessage}}</p>",
compileMessage: true
}
}
});
};
$scope.removeMarkers = function() {
$scope.data.markers = {};
}
$scope.addMarkers();
} ]);
app.controller('ViewController', ['$scope', function($scope) {
$scope.user = {}
$scope.greet = function(user) {
alert('hello ' + user.name)
}
} ]);
</script>
</head>
<body ng-controller="MarkersAngularTemplateController">
<leaflet lf-center="london" lf-markers="data.markers" height="480px" width="100%"></leaflet>
<h1>Markers angular template example</h1>
<button ng-click="removeMarkers()">Remove markers</button>
<button ng-click="addMarkers()">Add markers</button>
</body>
</html>