1
- /*! angular-google-maps 2.1.5 2015-08-09
1
+ /*! angular-google-maps 2.1.5 2015-08-16
2
2
* AngularJS directives for Google Maps
3
3
* git: https://github.com/angular-ui/angular-google-maps.git
4
4
*/
@@ -827,23 +827,23 @@ Nicholas McCready - https://twitter.com/nmccready
827
827
}).call(this);
828
828
;(function() {
829
829
angular.module('uiGmapgoogle-maps.directives.api.utils').service('uiGmapFitHelper', [
830
- 'uiGmapLogger', 'uiGmap_async', function($log, _async ) {
830
+ 'uiGmapLogger', function($log) {
831
831
return {
832
- fit: function(gMarkers , gMap) {
833
- var bounds, everSet;
834
- if (gMap && gMarkers && gMarkers .length > 0 ) {
832
+ fit: function(markersOrPoints , gMap) {
833
+ var bounds, everSet, key, markerOrPoint, point ;
834
+ if (gMap && (markersOrPoints != null ? markersOrPoints .length : void 0) ) {
835
835
bounds = new google.maps.LatLngBounds();
836
836
everSet = false;
837
- gMarkers.forEach((function(_this) {
838
- return function(gMarker) {
839
- if (gMarker) {
840
- if (!everSet) {
841
- everSet = true;
842
- }
843
- return bounds.extend(gMarker.getPosition());
837
+ for (key in markersOrPoints) {
838
+ markerOrPoint = markersOrPoints[key];
839
+ if (markerOrPoint) {
840
+ if (!everSet) {
841
+ everSet = true;
844
842
}
845
- };
846
- })(this));
843
+ point = _.isFunction(markerOrPoint.getPosition) ? markerOrPoint.getPosition() : markerOrPoint;
844
+ }
845
+ bounds.extend(point);
846
+ }
847
847
if (everSet) {
848
848
return gMap.fitBounds(bounds);
849
849
}
@@ -1097,16 +1097,6 @@ Nicholas McCready - https://twitter.com/nmccready
1097
1097
}
1098
1098
return result;
1099
1099
},
1100
- extendMapBounds: function(map, points) {
1101
- var bounds, i;
1102
- bounds = new google.maps.LatLngBounds();
1103
- i = 0;
1104
- while (i < points.length) {
1105
- bounds.extend(points.getAt(i));
1106
- i++;
1107
- }
1108
- return map.fitBounds(bounds);
1109
- },
1110
1100
getPath: function(object, key) {
1111
1101
var obj;
1112
1102
if ((key == null) || !_.isString(key)) {
@@ -2858,7 +2848,7 @@ Nicholas McCready - https://twitter.com/nmccready
2858
2848
2859
2849
BasePolyChildModel.include(GmapUtil);
2860
2850
2861
- function BasePolyChildModel(scope, attrs, map, defaults, model) {
2851
+ function BasePolyChildModel(scope, attrs, map, defaults, model, gObjectChangeCb ) {
2862
2852
var create;
2863
2853
this.scope = scope;
2864
2854
this.attrs = attrs;
@@ -2884,27 +2874,25 @@ Nicholas McCready - https://twitter.com/nmccready
2884
2874
};
2885
2875
create = (function(_this) {
2886
2876
return function() {
2887
- var maybeCachedEval, pathPoints ;
2877
+ var maybeCachedEval;
2888
2878
if (_this.isDragging) {
2889
2879
return;
2890
2880
}
2891
- pathPoints = _this.convertPathPoints(_this.scope.path);
2881
+ _this. pathPoints = _this.convertPathPoints(_this.scope.path);
2892
2882
if (_this.gObject != null) {
2893
2883
_this.clean();
2894
2884
}
2895
2885
if (_this.scope.model != null) {
2896
2886
maybeCachedEval = _this.scope;
2897
2887
}
2898
- if (pathPoints.length > 0) {
2899
- _this.gObject = gFactory(_this.buildOpts(pathPoints, maybeCachedEval));
2888
+ if (_this. pathPoints.length > 0) {
2889
+ _this.gObject = gFactory(_this.buildOpts(_this. pathPoints, maybeCachedEval));
2900
2890
}
2901
2891
if (_this.gObject) {
2902
- if (_this.scope.fit) {
2903
- _this.extendMapBounds(_this.map, pathPoints);
2904
- }
2905
2892
arraySync(_this.gObject.getPath(), _this.scope, 'path', function(pathPoints) {
2906
- if (_this.scope.fit) {
2907
- return _this.extendMapBounds(_this.map, pathPoints);
2893
+ _this.pathPoints = pathPoints;
2894
+ if (gObjectChangeCb != null) {
2895
+ return gObjectChangeCb();
2908
2896
}
2909
2897
});
2910
2898
if (angular.isDefined(_this.scope.events) && angular.isObject(_this.scope.events)) {
@@ -3936,7 +3924,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
3936
3924
hasProp = {}.hasOwnProperty;
3937
3925
3938
3926
angular.module('uiGmapgoogle-maps.directives.api.models.parent').factory('uiGmapBasePolysParentModel', [
3939
- '$timeout', 'uiGmapLogger', 'uiGmapModelKey', 'uiGmapModelsWatcher', 'uiGmapPropMap', 'uiGmap_async', 'uiGmapPromise', function($timeout, $log, ModelKey, ModelsWatcher, PropMap, _async, uiGmapPromise) {
3927
+ '$timeout', 'uiGmapLogger', 'uiGmapModelKey', 'uiGmapModelsWatcher', 'uiGmapPropMap', 'uiGmap_async', 'uiGmapPromise', 'uiGmapFitHelper', function($timeout, $log, ModelKey, ModelsWatcher, PropMap, _async, uiGmapPromise, FitHelper ) {
3940
3928
return function(IPoly, PolyChildModel, gObjectName) {
3941
3929
var BasePolysParentModel;
3942
3930
return BasePolysParentModel = (function(superClass) {
@@ -3949,6 +3937,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
3949
3937
this.attrs = attrs;
3950
3938
this.gMap = gMap1;
3951
3939
this.defaults = defaults;
3940
+ this.maybeFit = bind(this.maybeFit, this);
3952
3941
this.createChild = bind(this.createChild, this);
3953
3942
this.pieceMeal = bind(this.pieceMeal, this);
3954
3943
this.createAllNew = bind(this.createAllNew, this);
@@ -4075,15 +4064,17 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
4075
4064
return maybeCanceled = canceledMsg;
4076
4065
}), (function(_this) {
4077
4066
return function() {
4078
- return _async.each (scope.models, function(model) {
4067
+ return _async.map (scope.models, function(model) {
4079
4068
var child;
4080
4069
child = _this.createChild(model, _this.gMap);
4081
4070
if (maybeCanceled) {
4082
4071
$log.debug('createNew should fall through safely');
4083
4072
child.isEnabled = false;
4084
4073
}
4085
- return maybeCanceled;
4086
- }, _async.chunkSizeFrom(scope.chunk)).then(function() {
4074
+ maybeCanceled;
4075
+ return child.pathPoints.getArray();
4076
+ }, _async.chunkSizeFrom(scope.chunk)).then(function(pathPoints) {
4077
+ _this.maybeFit(pathPoints);
4087
4078
return _this.firstTime = false;
4088
4079
});
4089
4080
};
@@ -4127,7 +4118,9 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
4127
4118
}
4128
4119
_this.createChild(modelToAdd, _this.gMap);
4129
4120
return maybeCanceled;
4130
- }, _async.chunkSizeFrom(scope.chunk));
4121
+ }, _async.chunkSizeFrom(scope.chunk)).then(function() {
4122
+ return _this.maybeFit();
4123
+ });
4131
4124
});
4132
4125
};
4133
4126
})(this));
@@ -4149,7 +4142,11 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
4149
4142
};
4150
4143
})(this), true);
4151
4144
childScope["static"] = this.scope["static"];
4152
- child = new PolyChildModel(childScope, this.attrs, gMap, this.defaults, model);
4145
+ child = new PolyChildModel(childScope, this.attrs, gMap, this.defaults, model, (function(_this) {
4146
+ return function() {
4147
+ return _this.maybeFit();
4148
+ };
4149
+ })(this));
4153
4150
if (model[this.idKey] == null) {
4154
4151
this.$log.error(gObjectName + " model has no id to assign a child to.\nThis is required for performance. Please assign id,\nor redirect id to a different key.");
4155
4152
return;
@@ -4158,6 +4155,18 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
4158
4155
return child;
4159
4156
};
4160
4157
4158
+ BasePolysParentModel.prototype.maybeFit = function(pathPoints) {
4159
+ if (pathPoints == null) {
4160
+ pathPoints = this.plurals.map(function(p) {
4161
+ return p.pathPoints;
4162
+ });
4163
+ }
4164
+ if (this.scope.fit) {
4165
+ pathPoints = _.flatten(pathPoints);
4166
+ return FitHelper.fit(pathPoints, this.gMap);
4167
+ }
4168
+ };
4169
+
4161
4170
return BasePolysParentModel;
4162
4171
4163
4172
})(ModelKey);
@@ -6809,7 +6818,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
6809
6818
hasProp = {}.hasOwnProperty;
6810
6819
6811
6820
angular.module('uiGmapgoogle-maps.directives.api').factory('uiGmapPolygon', [
6812
- 'uiGmapIPolygon', '$timeout', 'uiGmaparray-sync', ' uiGmapPolygonChildModel', function(IPolygon, $timeout, arraySync , PolygonChild) {
6821
+ 'uiGmapIPolygon', '$timeout', 'uiGmapPolygonChildModel', function(IPolygon, $timeout, PolygonChild) {
6813
6822
var Polygon;
6814
6823
return Polygon = (function(superClass) {
6815
6824
extend(Polygon, superClass);
@@ -6848,7 +6857,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
6848
6857
hasProp = {}.hasOwnProperty;
6849
6858
6850
6859
angular.module('uiGmapgoogle-maps.directives.api').factory('uiGmapPolygons', [
6851
- 'uiGmapIPolygon', '$timeout', 'uiGmaparray-sync', ' uiGmapPolygonsParentModel', 'uiGmapPlural', function(Interface, $timeout, arraySync , ParentModel, Plural) {
6860
+ 'uiGmapIPolygon', '$timeout', 'uiGmapPolygonsParentModel', 'uiGmapPlural', function(Interface, $timeout, ParentModel, Plural) {
6852
6861
var Polygons;
6853
6862
return Polygons = (function(superClass) {
6854
6863
extend(Polygons, superClass);
@@ -6887,7 +6896,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
6887
6896
hasProp = {}.hasOwnProperty;
6888
6897
6889
6898
angular.module('uiGmapgoogle-maps.directives.api').factory('uiGmapPolyline', [
6890
- 'uiGmapIPolyline', '$timeout', 'uiGmaparray-sync', ' uiGmapPolylineChildModel', function(IPolyline, $timeout, arraySync , PolylineChildModel) {
6899
+ 'uiGmapIPolyline', '$timeout', 'uiGmapPolylineChildModel', function(IPolyline, $timeout, PolylineChildModel) {
6891
6900
var Polyline;
6892
6901
return Polyline = (function(superClass) {
6893
6902
extend(Polyline, superClass);
@@ -6921,7 +6930,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
6921
6930
hasProp = {}.hasOwnProperty;
6922
6931
6923
6932
angular.module('uiGmapgoogle-maps.directives.api').factory('uiGmapPolylines', [
6924
- 'uiGmapIPolyline', '$timeout', 'uiGmaparray-sync', ' uiGmapPolylinesParentModel', 'uiGmapPlural', function(IPolyline, $timeout, arraySync , PolylinesParentModel, Plural) {
6933
+ 'uiGmapIPolyline', '$timeout', 'uiGmapPolylinesParentModel', 'uiGmapPlural', function(IPolyline, $timeout, PolylinesParentModel, Plural) {
6925
6934
var Polylines;
6926
6935
return Polylines = (function(superClass) {
6927
6936
extend(Polylines, superClass);
0 commit comments