Skip to content

Commit c9218f3

Browse files
committed
Merge branch 'master' of github.com:tombatossals/angular-leaflet-directive
2 parents 5c927ab + 85ca36c commit c9218f3

File tree

4 files changed

+29
-16
lines changed

4 files changed

+29
-16
lines changed

dist/angular-leaflet-directive.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,12 @@ angular.module("leaflet-directive").directive('center',
200200
zoom: map.getZoom(),
201201
autoDiscover: false
202202
};
203+
angular.extend(scope.center,{
204+
lat: map.getCenter().lat,
205+
lng: map.getCenter().lng,
206+
zoom: map.getZoom(),
207+
autoDiscover: false
208+
});
203209
});
204210
safeApply(leafletScope, function (scope) {
205211
var mapBounds = map.getBounds();
@@ -311,12 +317,13 @@ angular.module("leaflet-directive").directive('center',
311317
safeApply(leafletScope, function(scope) {
312318
if (!leafletScope.settingCenterFromScope) {
313319
//$log.debug("updating center model...", map.getCenter(), map.getZoom());
314-
scope.center = {
315-
lat: map.getCenter().lat,
316-
lng: map.getCenter().lng,
317-
zoom: map.getZoom(),
318-
autoDiscover: false
319-
};
320+
321+
angular.extend(scope.center,{
322+
lat: map.getCenter().lat,
323+
lng: map.getCenter().lng,
324+
zoom: map.getZoom(),
325+
autoDiscover: false
326+
});
320327
}
321328
leafletEvents.notifyCenterChangedToBounds(leafletScope, map);
322329
});

dist/angular-leaflet-directive.min.js

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

doc/bounds-attribute.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
This sub-directive needs the **leaflet** main directive, so it is normaly used as an attribute of the *leaflet* tag, like this:
55

66
```
7-
<leaflet bounds="bounds"></leaflet>
7+
<leaflet bounds="bounds" center="center"></leaflet>
88
```
99

1010
It will map an object _bounds_ of our controller scope with the corresponding object on our leaflet directive isolated scope. It's a bidirectional relationship, so a change in this object on the controller scope object will affect the map bounds, or an interaction on the map which changes the map position will update our _bounds_ values. Let's define the bounds model with an example:

src/directives/center.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ angular.module("leaflet-directive").directive('center',
4646
zoom: map.getZoom(),
4747
autoDiscover: false
4848
};
49+
angular.extend(scope.center,{
50+
lat: map.getCenter().lat,
51+
lng: map.getCenter().lng,
52+
zoom: map.getZoom(),
53+
autoDiscover: false
54+
});
4955
});
5056
safeApply(leafletScope, function (scope) {
5157
var mapBounds = map.getBounds();
@@ -157,12 +163,13 @@ angular.module("leaflet-directive").directive('center',
157163
safeApply(leafletScope, function(scope) {
158164
if (!leafletScope.settingCenterFromScope) {
159165
//$log.debug("updating center model...", map.getCenter(), map.getZoom());
160-
scope.center = {
161-
lat: map.getCenter().lat,
162-
lng: map.getCenter().lng,
163-
zoom: map.getZoom(),
164-
autoDiscover: false
165-
};
166+
167+
angular.extend(scope.center,{
168+
lat: map.getCenter().lat,
169+
lng: map.getCenter().lng,
170+
zoom: map.getZoom(),
171+
autoDiscover: false
172+
});
166173
}
167174
leafletEvents.notifyCenterChangedToBounds(leafletScope, map);
168175
});

0 commit comments

Comments
 (0)