angular-leaflet-rails 0.1.0.3 → 0.1.0.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 822a1aa810952f40ab06b6d6ed9325afabb926a6
|
4
|
+
data.tar.gz: 102855448f080283587c21ae53b3522a5ea236f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 492cb5313f007fdcad609641ffcb8070319a05bf52ee1fbfec5b235678899c191a135c92bfc870346f15dc7e9332d179fa1ef096f7144c2664f2c4dd83663af5
|
7
|
+
data.tar.gz: 34c034f153e69a1162c0aa0b3d4f0af646db84b75185280263dea8e4e108bb06c2f471182a7f1dd0faf27db73fc3364a15af7147f6e4cfbf293d7f8e52f61196
|
@@ -9,6 +9,7 @@ leafletDirective.directive("leaflet", ["$http", "$log", function ($http, $log) {
|
|
9
9
|
center: "=center",
|
10
10
|
tilelayer: "=tilelayer",
|
11
11
|
markers: "=markers",
|
12
|
+
leafletMarkers: "=leafletMarkers",
|
12
13
|
path: "=path",
|
13
14
|
maxZoom: "@maxzoom"
|
14
15
|
},
|
@@ -39,7 +40,7 @@ leafletDirective.directive("leaflet", ["$http", "$log", function ($http, $log) {
|
|
39
40
|
if (attrs.center && scope.center) {
|
40
41
|
|
41
42
|
if (scope.center.lat && scope.center.lng && scope.center.zoom) {
|
42
|
-
map.setView(
|
43
|
+
map.setView([scope.center.lat, scope.center.lng], scope.center.zoom);
|
43
44
|
} else if (scope.center.autoDiscover === true) {
|
44
45
|
map.locate({ setView: true, maxZoom: maxZoom });
|
45
46
|
}
|
@@ -52,9 +53,11 @@ leafletDirective.directive("leaflet", ["$http", "$log", function ($http, $log) {
|
|
52
53
|
});
|
53
54
|
|
54
55
|
map.on("zoomend", function(e) {
|
55
|
-
scope
|
56
|
-
|
57
|
-
|
56
|
+
if (scope.center.zoom !== map.getZoom()){
|
57
|
+
scope.$apply(function (s) {
|
58
|
+
s.center.zoom = map.getZoom();
|
59
|
+
});
|
60
|
+
}
|
58
61
|
});
|
59
62
|
|
60
63
|
scope.$watch("center", function (center, oldValue) {
|
@@ -65,8 +68,6 @@ leafletDirective.directive("leaflet", ["$http", "$log", function ($http, $log) {
|
|
65
68
|
}
|
66
69
|
|
67
70
|
if (attrs.markers && scope.markers) {
|
68
|
-
var markers = {};
|
69
|
-
|
70
71
|
var createAndLinkMarker = function(key, scope) {
|
71
72
|
var data = scope.markers[key];
|
72
73
|
var marker = new L.marker(
|
@@ -89,7 +90,10 @@ leafletDirective.directive("leaflet", ["$http", "$log", function ($http, $log) {
|
|
89
90
|
scope.$watch('markers.' + key, function(newval, oldval) {
|
90
91
|
if (!newval) {
|
91
92
|
map.removeLayer(markers[key]);
|
92
|
-
delete
|
93
|
+
delete leafletMarkers[key];
|
94
|
+
if (attrs.leafletMarkers) {
|
95
|
+
delete scope.leafletMarkers[key];
|
96
|
+
}
|
93
97
|
return;
|
94
98
|
}
|
95
99
|
|
@@ -113,13 +117,33 @@ leafletDirective.directive("leaflet", ["$http", "$log", function ($http, $log) {
|
|
113
117
|
return marker;
|
114
118
|
}; // end of create and link marker
|
115
119
|
|
120
|
+
var leafletMarkers = {}
|
121
|
+
|
122
|
+
// Expose the map object, for testing purposes
|
123
|
+
if (attrs.leafletMarkers) {
|
124
|
+
scope.leafletMarkers = {};
|
125
|
+
}
|
126
|
+
|
127
|
+
// Create the initial objects
|
128
|
+
for (var key in scope.markers) {
|
129
|
+
var marker = createAndLinkMarker(key, scope);
|
130
|
+
map.addLayer(marker);
|
131
|
+
leafletMarkers[key] = marker;
|
132
|
+
if (attrs.leafletMarkers) {
|
133
|
+
scope.leafletMarkers[key] = marker;
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
116
137
|
scope.$watch("markers", function(newMarkerList) {
|
117
138
|
// add new markers
|
118
|
-
for (var key in
|
119
|
-
if (
|
139
|
+
for (var key in newMarkerList) {
|
140
|
+
if (leafletMarkers[key] === undefined) {
|
120
141
|
var marker = createAndLinkMarker(key, scope);
|
121
142
|
map.addLayer(marker);
|
122
|
-
|
143
|
+
leafletMarkers[key] = marker;
|
144
|
+
if (attrs.leafletMarkers) {
|
145
|
+
scope.leafletMarkers[key] = marker;
|
146
|
+
}
|
123
147
|
}
|
124
148
|
}
|
125
149
|
}, true);
|