forked from tombatossals/angular-leaflet-directive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0301-paths-types-example.html
115 lines (108 loc) · 4.43 KB
/
0301-paths-types-example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<!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="../bower_components/angular-simple-logger/dist/angular-simple-logger.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('PathTypesController', [ '$scope', function($scope) {
var europeCapitals = {
Madrid: {
lat: 40.4,
lng: -3.6833333
},
Rome: {
lat: 41.9,
lng: 12.4833333
},
London: {
lat: 51.5,
lng: -0.116667
},
Lisbon: {
lat: 38.7166667,
lng: -9.1333333
},
Berlin: {
lat: 52.5166667,
lng: 13.4
},
Paris: {
lat: 48.866667,
lng: 2.333333
},
Brussels: {
lat: 50.8333,
lng: 4
}
};
var pathsDict = {
polyline: {
type: "polyline",
latlngs: [ europeCapitals.London, europeCapitals.Madrid, europeCapitals.Rome ]
},
multiPolyline: {
type: "multiPolyline",
latlngs: [
[ europeCapitals.London, europeCapitals.Lisbon ],
[ europeCapitals.Paris, europeCapitals.Madrid ],
[ europeCapitals.Rome, europeCapitals.Berlin ]
]
},
polygon: {
type: "polygon",
latlngs: [ europeCapitals.London, europeCapitals.Lisbon , europeCapitals.Madrid, europeCapitals.Paris ]
},
multiPolygon: {
type: "multiPolygon",
latlngs: [
[ europeCapitals.London, europeCapitals.Lisbon , europeCapitals.Madrid, europeCapitals.Paris ],
[ europeCapitals.Berlin, europeCapitals.Rome, europeCapitals.Brussels ]
]
},
rectangle: {
type: "rectangle",
latlngs: [ europeCapitals.Berlin, europeCapitals.Lisbon ]
},
circle: {
type: "circle",
radius: 500 * 1000,
latlngs: europeCapitals.Brussels
},
circleMarker: {
type: "circleMarker",
radius: 50,
latlngs: europeCapitals.Rome
}
};
angular.extend($scope, {
center: {
lat: 51.505,
lng: -0.09,
zoom: 3
},
paths: {}
});
$scope.addShape = function(shape) {
$scope.paths = {};
$scope.paths[shape] = pathsDict[shape];
};
} ]);
</script>
</head>
<body ng-controller="PathTypesController">
<leaflet lf-center="center" paths="paths" width="100%" height="480px"></leaflet>
<h1>Types of paths</h1>
<button type="button" ng-click="addShape('polyline')" class="btn btn-default">polyline</button>
<button type="button" ng-click="addShape('multiPolyline')" class="btn btn-default">multiPolyline</button>
<button type="button" ng-click="addShape('polygon')" class="btn btn-default">polygon</button>
<button type="button" ng-click="addShape('multiPolygon')" class="btn btn-default">multiPolygon</button>
<button type="button" ng-click="addShape('rectangle')" class="btn btn-default">rectangle</button>
<button type="button" ng-click="addShape('circle')" class="btn btn-default">circle</button>
<button type="button" ng-click="addShape('circleMarker')" class="btn btn-default">circleMarker</button>
</body>
</html>