Skip to content
This repository was archived by the owner on Sep 20, 2019. It is now read-only.

Commit 99ca74f

Browse files
committed
feat(examples): new example of paths with ajax loading of data
1 parent 2c29dfd commit 99ca74f

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

examples/json/paths.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"p1": {
3+
"color": "red",
4+
"weight": 8,
5+
"latlngs": [
6+
{ "lat": 51.50, "lng": -0.082 },
7+
{ "lat": 48.83, "lng": 2.37 },
8+
{ "lat": 41.91, "lng": 12.48 }
9+
],
10+
"message": "<h3>Route from London to Rome</h3><p>Distance: 1862km</p>"
11+
},
12+
"p2": {
13+
"color": "green",
14+
"weight": 8,
15+
"latlngs": [
16+
{ "lat": 48.2083537, "lng": 16.3725042 },
17+
{ "lat": 48.8534, "lng": 2.3485 }
18+
],
19+
"label": { "message": "<h3>Route from Vienna to Paris</h3><p>Distance: 1211km</p>"}
20+
}
21+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!DOCTYPE html>
2+
<html ng-app="demoapp">
3+
<head>
4+
<script src="../bower_components/angular/angular.min.js"></script>
5+
<script src="../bower_components/leaflet/dist/leaflet.js"></script>
6+
<script src="../bower_components/Leaflet.label/dist/leaflet.label.js"></script>
7+
<script src="../dist/angular-leaflet-directive.js"></script>
8+
<link rel="stylesheet" href="../bower_components/leaflet/dist/leaflet.css" />
9+
<link rel="stylesheet" href="../bower_components/Leaflet.label/dist/leaflet.label.css" />
10+
<script>
11+
var app = angular.module("demoapp", ["leaflet-directive"]);
12+
app.controller("DemoController", [ "$scope", "$http", function($scope, $http) {
13+
angular.extend($scope, {
14+
london: {
15+
lat: 51.505,
16+
lng: -0.09,
17+
zoom: 4
18+
},
19+
europeanPaths: {}
20+
});
21+
22+
$scope.loadPaths = function loadPaths() {
23+
$http.get('json/paths.json').success(function(data) {
24+
$scope.europeanPaths = data;
25+
});
26+
};
27+
28+
}]);
29+
</script>
30+
<style>
31+
.angular-leaflet-map {
32+
width: 640px;
33+
height: 400px;
34+
}
35+
</style>
36+
</head>
37+
<body ng-controller="DemoController">
38+
<leaflet center="london" paths="europeanPaths"></leaflet>
39+
<p>Click on red route (Popup) or hover over green route (Label) to get more information</p>
40+
<button ng-click="loadPaths()">Load Paths data!</button>
41+
</body>
42+
</html>

0 commit comments

Comments
 (0)