mohsen-angular-leaflet-directive
Version:
angular-leaflet-directive - An AngularJS directive to easily interact with Leaflet maps
69 lines (63 loc) • 2.69 kB
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="../bower_components/Leaflet.heat/dist/leaflet-heat.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("LayersHeatmapController", ["$scope", "$http", function($scope, $http) {
var points = [];
var heatmap = {
name: 'Heat Map',
type: 'heat',
data: points,
visible: true
};
$http.get("json/heat-points.json").success(function(data) {
$scope.layers.overlays = {
heat: {
name: 'Heat Map',
type: 'heat',
data: data,
layerOptions: {
radius: 20,
blur: 10
},
visible: true
}
};
});
angular.extend($scope, {
center: {
lat: 37.774546,
lng: -122.433523,
zoom: 12
},
layers: {
baselayers: {
mapbox_light: {
name: 'Mapbox Light',
url: 'http://api.tiles.mapbox.com/v4/{mapid}/{z}/{x}/{y}.png?access_token={apikey}',
type: 'xyz',
layerOptions: {
apikey: 'pk.eyJ1IjoiYnVmYW51dm9scyIsImEiOiJLSURpX0pnIn0.2_9NrLz1U9bpwMQBhVk97Q',
mapid: 'bufanuvols.lia22g09'
}
}
}
}
});
}]);
</script>
</head>
<body ng-controller="LayersHeatmapController">
<leaflet lf-center="center" lf-layers="layers" width="100%" height="480px"></leaflet>
<h1>HeatMap example</h1>
<p>This example uses the <a href="https://github.com/Leaflet/Leaflet.heat">Leaflet.heat</a> library.</p>
<p>The example is inspired in <a href="https://developers.google.com/maps/documentation/javascript/examples/layer-heatmap?hl=es">this</a> Google Maps Heat example.</p>
</body>
</html>