Skip to content

Commit 7d1dac7

Browse files
fixed merge and extended simple path example
1 parent 1b52ea6 commit 7d1dac7

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

dist/angular-leaflet-directive.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,9 +803,14 @@
803803
if (!isDefined(leafletPaths[newName])) {
804804
var pathData = newPaths[newName];
805805
var newPath = createPath(newName, newPaths[newName], defaults);
806+
// bind popup if defined
806807
if (isDefined(newPath) && isDefined(pathData.message)) {
807808
newPath.bindPopup(pathData.message);
808809
}
810+
// Show label if defined
811+
if (leafletHelpers.LabelPlugin.isLoaded() && isDefined(pathData.label) && isDefined(pathData.label.message)) {
812+
newPath.bindLabel(pathData.label.message, pathData.label.options);
813+
}
809814
// Listen for changes on the new path
810815
if (isDefined(newPath)) {
811816
leafletPaths[newName] = newPath;

dist/angular-leaflet-directive.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/paths-simple-example.html

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
<head>
44
<script src="../bower_components/angular/angular.min.js"></script>
55
<script src="../bower_components/leaflet-dist/leaflet.js"></script>
6-
<script src="../dist/angular-leaflet-directive.min.js"></script>
6+
<script src="../bower_components/Leaflet.label/dist/leaflet.label.js"></script>
7+
<script src="../dist/angular-leaflet-directive.js"></script>
78
<link rel="stylesheet" href="../bower_components/leaflet-dist/leaflet.css" />
9+
<link rel="stylesheet" href="../bower_components/Leaflet.label/dist/leaflet.label.css" />
810
<script>
911
var app = angular.module("demoapp", ["leaflet-directive"]);
1012
app.controller("DemoController", [ "$scope", function($scope) {
@@ -23,8 +25,18 @@
2325
{ lat: 48.83, lng: 2.37 },
2426
{ lat: 41.91, lng: 12.48 }
2527
],
26-
message: "<h3>Route from London to Rome</h3><p>Distance: 1862km</p>"
28+
message: "<h3>Route from London to Rome</h3><p>Distance: 1862km</p>",
29+
},
30+
p2: {
31+
color: 'green',
32+
weight: 8,
33+
latlngs: [
34+
{ lat: 48.2083537, lng: 16.3725042 },
35+
{ lat: 48.8534, lng: 2.3485 }
36+
],
37+
label: {message: "<h3>Route from Vienna to Paris</h3><p>Distance: 1211km</p>"}
2738
}
39+
2840
}
2941
});
3042
}]);
@@ -38,6 +50,6 @@
3850
</head>
3951
<body ng-controller="DemoController">
4052
<leaflet center="london" paths="europeanPaths"></leaflet>
41-
<p>Click on the route to get more information</p>
53+
<p>Click on red route (Popup) or hover over green route (Label) to get more information</p>
4254
</body>
4355
</html>

src/directives/paths.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,16 @@ angular.module("leaflet-directive").directive('paths', function ($log, leafletDa
4242
var pathData = newPaths[newName];
4343
var newPath = createPath(newName, newPaths[newName], defaults);
4444

45+
// bind popup if defined
4546
if (isDefined(newPath) && isDefined(pathData.message)) {
4647
newPath.bindPopup(pathData.message);
4748
}
4849

50+
// Show label if defined
51+
if (leafletHelpers.LabelPlugin.isLoaded() && isDefined(pathData.label) && isDefined(pathData.label.message)) {
52+
newPath.bindLabel(pathData.label.message, pathData.label.options);
53+
}
54+
4955
// Listen for changes on the new path
5056
if (isDefined(newPath)) {
5157
leafletPaths[newName] = newPath;

0 commit comments

Comments
 (0)