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: 2dbd98dbdb5bd6d2f60c447e83171a961fbcaaa0
4
- data.tar.gz: 48d8a8dea0ca7ce2fd8ac50615c9082724417cc4
3
+ metadata.gz: 822a1aa810952f40ab06b6d6ed9325afabb926a6
4
+ data.tar.gz: 102855448f080283587c21ae53b3522a5ea236f8
5
5
  SHA512:
6
- metadata.gz: 0cb868ebfb1000e9ad8a117c3ef571f01d642a2891d8cbc7db202892913762cfee4c1c8907249c723e091d2f4b15a003de063e3913a2e19d08ffe51ea40be3fe
7
- data.tar.gz: 0dcc291e9ff174086bb3096df6a4866b7aa9717cb4e2e541d74335b4000064852aaacd27344aa033d02050a64741bdff58b4ea00998b136a31e4c6979d7c06c6
6
+ metadata.gz: 492cb5313f007fdcad609641ffcb8070319a05bf52ee1fbfec5b235678899c191a135c92bfc870346f15dc7e9332d179fa1ef096f7144c2664f2c4dd83663af5
7
+ data.tar.gz: 34c034f153e69a1162c0aa0b3d4f0af646db84b75185280263dea8e4e108bb06c2f471182a7f1dd0faf27db73fc3364a15af7147f6e4cfbf293d7f8e52f61196
@@ -1,5 +1,5 @@
1
1
  module AngularLeaflet
2
2
  module Rails
3
- VERSION = "0.1.0.3"
3
+ VERSION = "0.1.0.4"
4
4
  end
5
5
  end
@@ -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(new L.LatLng(scope.center.lat, scope.center.lng), scope.center.zoom);
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.$apply(function (s) {
56
- s.center.zoom = map.getZoom();
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 markers[key];
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 scope.markers) {
119
- if (markers[key] === undefined) {
139
+ for (var key in newMarkerList) {
140
+ if (leafletMarkers[key] === undefined) {
120
141
  var marker = createAndLinkMarker(key, scope);
121
142
  map.addLayer(marker);
122
- markers[key] = marker;
143
+ leafletMarkers[key] = marker;
144
+ if (attrs.leafletMarkers) {
145
+ scope.leafletMarkers[key] = marker;
146
+ }
123
147
  }
124
148
  }
125
149
  }, true);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: angular-leaflet-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.3
4
+ version: 0.1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tymon Tobolski