Skip to content

Commit

Permalink
fix(url-center): round the latlng to 4 digits as suggested by @fbuchi…
Browse files Browse the repository at this point in the history
  • Loading branch information
tombatossals committed Mar 19, 2014
1 parent 21bacce commit 4a6d755
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/angular-leaflet-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
return;
}
var center = map.getCenter();
var centerUrlHash = center.lat + ':' + center.lng + ':' + map.getZoom();
var centerUrlHash = center.lat.toFixed(4) + ':' + center.lng.toFixed(4) + ':' + map.getZoom();
var search = $location.search();
if (!isDefined(search.c) || search.c !== centerUrlHash) {
//$log.debug("notified new center...");
Expand Down
6 changes: 3 additions & 3 deletions dist/angular-leaflet-directive.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/directives/center.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ angular.module("leaflet-directive").directive('center',
return;
}
var center = map.getCenter();
var centerUrlHash = center.lat + ":" + center.lng + ":" + map.getZoom();
var centerUrlHash = (center.lat).toFixed(4) + ":" + (center.lng).toFixed(4) + ":" + map.getZoom();
var search = $location.search();
if (!isDefined(search.c) || search.c !== centerUrlHash) {
//$log.debug("notified new center...");
Expand Down
2 changes: 1 addition & 1 deletion test/unit/centerDirectiveSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('Directive: leaflet center', function() {
centerUrlHash = u;
});
scope.$digest();
expect(centerUrlHash).toBe('9.5:-1.8:8');
expect(centerUrlHash).toBe('9.5000:-1.8000:8');
});
});
});
1 change: 0 additions & 1 deletion test/unit/layersDirectiveSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,6 @@ describe('Directive: leaflet', function() {
layer: 'cars'
};
scope.$digest();
console.log(scope.markers.m1);
expect(map.hasLayer(markers.m1)).toBe(true); //Fail
expect(layers.overlays.cars.hasLayer(markers.m1)).toBe(true);

Expand Down

0 comments on commit 4a6d755

Please sign in to comment.