1
- /*! angular-google-maps 2.3.2 2016-02-11
1
+ /*! angular-google-maps 2.3.2 2016-04-25
2
2
* AngularJS directives for Google Maps
3
3
* git: https://github.com/angular-ui/angular-google-maps.git
4
4
*/
@@ -1036,7 +1036,7 @@ Nicholas McCready - https://twitter.com/nmccready
1036
1036
}).call(this);
1037
1037
;(function() {
1038
1038
angular.module('uiGmapgoogle-maps.directives.api.utils').service('uiGmapFitHelper', [
1039
- 'uiGmapLogger', function($log) {
1039
+ 'uiGmapLogger', '$timeout', function($log, $timeout ) {
1040
1040
return {
1041
1041
fit: function(markersOrPoints, gMap) {
1042
1042
var bounds, everSet, key, markerOrPoint, point;
@@ -1054,7 +1054,9 @@ Nicholas McCready - https://twitter.com/nmccready
1054
1054
bounds.extend(point);
1055
1055
}
1056
1056
if (everSet) {
1057
- return gMap.fitBounds(bounds);
1057
+ return $timeout(function() {
1058
+ return gMap.fitBounds(bounds);
1059
+ });
1058
1060
}
1059
1061
}
1060
1062
}
@@ -1098,7 +1100,9 @@ Nicholas McCready - https://twitter.com/nmccready
1098
1100
if (!value) {
1099
1101
return;
1100
1102
}
1101
- if (Array.isArray(value) && value.length === 2) {
1103
+ if (value instanceof google.maps.LatLng) {
1104
+ return value;
1105
+ } else if (Array.isArray(value) && value.length === 2) {
1102
1106
return new google.maps.LatLng(value[1], value[0]);
1103
1107
} else if (angular.isDefined(value.type) && value.type === 'Point') {
1104
1108
return new google.maps.LatLng(value.coordinates[1], value.coordinates[0]);
@@ -6644,7 +6648,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
6644
6648
};
6645
6649
6646
6650
Map.prototype.link = function(scope, element, attrs) {
6647
- var listeners, unbindCenterWatch ;
6651
+ var listeners;
6648
6652
listeners = [];
6649
6653
scope.$on('$destroy', function() {
6650
6654
uiGmapEventsHelper.removeEvents(listeners);
@@ -6654,18 +6658,6 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
6654
6658
}
6655
6659
});
6656
6660
scope.idleAndZoomChanged = false;
6657
- if (scope.center == null) {
6658
- unbindCenterWatch = scope.$watch('center', (function(_this) {
6659
- return function() {
6660
- if (!scope.center) {
6661
- return;
6662
- }
6663
- unbindCenterWatch();
6664
- return _this.link(scope, element, attrs);
6665
- };
6666
- })(this));
6667
- return;
6668
- }
6669
6661
return uiGmapGoogleMapApi.then((function(_this) {
6670
6662
return function(maps) {
6671
6663
var _gMap, customListeners, disabledEvents, dragging, el, eventName, getEventHandler, mapOptions, maybeHookToEvent, opts, ref, resolveSpawned, settingFromDirective, spawned, type, updateCenter, zoomPromise;
@@ -6679,13 +6671,15 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
6679
6671
map: _gMap
6680
6672
});
6681
6673
};
6682
- if (!_this.validateCoords (scope.center)) {
6683
- $log.error('angular-google-maps: could not find a valid center property ');
6674
+ if (!angular.isDefined (scope.center) && !angular.isDefined(scope.bounds )) {
6675
+ $log.error('angular-google-maps: a center or bounds property is required ');
6684
6676
return;
6685
6677
}
6678
+ if (!angular.isDefined(scope.center)) {
6679
+ scope.center = new google.maps.LatLngBounds(_this.getCoords(scope.bounds.southwest), _this.getCoords(scope.bounds.northeast)).getCenter();
6680
+ }
6686
6681
if (!angular.isDefined(scope.zoom)) {
6687
- $log.error('angular-google-maps: map zoom property not set');
6688
- return;
6682
+ scope.zoom = 10;
6689
6683
}
6690
6684
el = angular.element(element);
6691
6685
el.addClass('angular-google-map');
@@ -6764,16 +6758,6 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
6764
6758
s = scope;
6765
6759
}
6766
6760
if (_.includes(disabledEvents, 'center')) {
6767
- return;
6768
- }
6769
- if (angular.isDefined(s.center.type)) {
6770
- if (s.center.coordinates[1] !== c.lat()) {
6771
- s.center.coordinates[1] = c.lat();
6772
- }
6773
- if (s.center.coordinates[0] !== c.lng()) {
6774
- return s.center.coordinates[0] = c.lng();
6775
- }
6776
- } else {
6777
6761
if (s.center.latitude !== c.lat()) {
6778
6762
s.center.latitude = c.lat();
6779
6763
}
0 commit comments