Skip to content

Commit

Permalink
fix(center): Fix bug with scope.center
Browse files Browse the repository at this point in the history
  • Loading branch information
Idan Lahav committed Sep 2, 2015
1 parent ec0fe74 commit 277ebc5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/directives/center.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ angular.module("leaflet-directive").directive('center',
}

leafletScope.$watch("center", function(center) {
if (scope.settingCenterFromLeaflet)
if (leafletScope.settingCenterFromLeaflet)
return;
//$log.debug("updated center model...");
// The center from the URL has priority
Expand Down Expand Up @@ -153,11 +153,11 @@ angular.module("leaflet-directive").directive('center',
_leafletCenter.resolve();
leafletEvents.notifyCenterUrlHashChanged(leafletScope, map, attrs, $location.search());
//$log.debug("updated center on map...");
if (isSameCenterOnMap(centerModel, map) || scope.settingCenterFromScope) {
if (isSameCenterOnMap(centerModel, map) || leafletScope.settingCenterFromScope) {
//$log.debug("same center in model, no need to update again.");
return;
}
scope.settingCenterFromLeaflet = true;
leafletScope.settingCenterFromLeaflet = true;
safeApply(leafletScope, function(scope) {
if (!leafletScope.settingCenterFromScope) {
//$log.debug("updating center model...", map.getCenter(), map.getZoom());
Expand All @@ -170,7 +170,7 @@ angular.module("leaflet-directive").directive('center',
}
leafletEvents.notifyCenterChangedToBounds(leafletScope, map);
$timeout( function() {
scope.settingCenterFromLeaflet = false;
leafletScope.settingCenterFromLeaflet = false;
});
});
});
Expand Down

0 comments on commit 277ebc5

Please sign in to comment.