Skip to content

Commit

Permalink
Merge pull request #13 from goooseman/patch-1
Browse files Browse the repository at this point in the history
FIX #12
  • Loading branch information
just-boris committed Sep 14, 2015
2 parents edbc139 + 591e4ad commit 3416495
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions angular-ymaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,14 @@ angular.module('ymaps', [])
function initAutoFit(map, collection, ymaps) {
collection.events.add('boundschange', debounce(function () {
if(collection.getLength() > 0) {
var maxZoomBefore = map.options.get('maxZoom');
map.options.set('maxZoom', $scope.zoom);
map.setBounds(collection.getBounds(), {
checkZoomRange: true,
zoomMargin: config.fitMarkersZoomMargin
}).then(function () {
map.options.set('maxZoom', maxZoomBefore);
map.setZoom(map.getZoom()); // Setting current zoom. Without this the plus button on the yandex map doesn't get updated after .set('maxZoom').
});
}
}, 100));
Expand Down
11 changes: 8 additions & 3 deletions spec/ymaps.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,18 @@ describe('Ymaps', function() {
$provide.value('debounce', angular.identity);
$provide.factory('ymapsLoader', function($q) {
mapMock = {
options: jasmine.createSpyObj('mapOptions', ['get', 'set']),
events: jasmine.createSpyObj('mapEvents', ['add']),
panTo: jasmine.createSpy('panSpy').and.callFake(function() {
this.deferred = $q.defer();
this.deferred.promise.always = this.deferred.promise.finally;
return this.deferred.promise;
}),
setBounds: jasmine.createSpy('mapBounds'),
setBounds: jasmine.createSpy('mapBounds').and.callFake(function() {
this.deferred = $q.defer();
this.deferred.promise.always = this.deferred.promise.finally;
return this.deferred.promise;
}),
setZoom: jasmine.createSpy('zoomSpy'),
controls: jasmine.createSpyObj('mapObjControls', ['add']),
geoObjects: jasmine.createSpyObj('mapObjElements', ['add'])
Expand All @@ -69,7 +74,7 @@ describe('Ymaps', function() {
GeoObjectCollection: jasmine.createSpy('geoObjectsCollection').and.returnValue(geoObjectsMock),
Placemark: jasmine.createSpy('placemark').and.returnValue(placemarkMock)
};
return {
return {
ready: function(callback) {callback(ymapsMock);}
};
});
Expand Down Expand Up @@ -146,7 +151,7 @@ describe('Ymaps', function() {
scope.$apply();
callback(new YaEvent({newCenter: [62.16, 34.56], newZoom: 23}));
expect(scope.center).toEqual([62.16, 34.56]);
});
});

it('should add nested markers to map', function() {
createElement(
Expand Down

0 comments on commit 3416495

Please sign in to comment.