Skip to content

Commit ff88b09

Browse files
[Added allenhwkim#422] Added maximum-zoom as option so you can place a zoom limit when zoom-to-include-markers resizes the map.
1 parent bf65e1a commit ff88b09

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

controllers/map-controller.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
for (var k2 in vm.map.customMarkers) {
103103
bounds.extend(vm.map.customMarkers[k2].getPosition());
104104
}
105+
if (vm.mapOptions.maximumZoom) {
106+
vm.enableMaximumZoomCheck = true; //enable zoom check after resizing for markers
107+
}
105108
vm.map.fitBounds(bounds);
106109
};
107110

@@ -210,6 +213,18 @@
210213
$parse($attrs.mapInitialized)($scope, {map: vm.map});
211214
}
212215
});
216+
217+
//add maximum zoom listeners if zoom-to-include-markers and and maximum-zoom are valid attributes
218+
if (mapOptions.zoomToIncludeMarkers && mapOptions.maximumZoom) {
219+
google.maps.event.addListener(vm.map, 'zoom_changed', function() {
220+
if (vm.enableMaximumZoomCheck == true) {
221+
vm.enableMaximumZoomCheck = false;
222+
google.maps.event.addListenerOnce(vm.map, 'bounds_changed', function() {
223+
vm.map.setZoom(Math.min(mapOptions.maximumZoom, vm.map.getZoom()));
224+
});
225+
}
226+
});
227+
}
213228
};
214229

215230
$scope.google = google; //used by $scope.eval to avoid eval()

0 commit comments

Comments
 (0)