Skip to content
This repository was archived by the owner on Nov 30, 2018. It is now read-only.

Commit aca29aa

Browse files
committed
fixes issue #1436
1 parent 64393df commit aca29aa

16 files changed

+231
-156
lines changed

dist/angular-google-maps-street-view.js

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! angular-google-maps 2.1.5 2015-08-09
1+
/*! angular-google-maps 2.1.5 2015-08-16
22
* AngularJS directives for Google Maps
33
* git: https://github.com/angular-ui/angular-google-maps.git
44
*/
@@ -469,16 +469,6 @@ return UUID;
469469
}
470470
return result;
471471
},
472-
extendMapBounds: function(map, points) {
473-
var bounds, i;
474-
bounds = new google.maps.LatLngBounds();
475-
i = 0;
476-
while (i < points.length) {
477-
bounds.extend(points.getAt(i));
478-
i++;
479-
}
480-
return map.fitBounds(bounds);
481-
},
482472
getPath: function(object, key) {
483473
var obj;
484474
if ((key == null) || !_.isString(key)) {

dist/angular-google-maps-street-view_dev_mapped.js

Lines changed: 1 addition & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-google-maps-street-view_dev_mapped.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-google-maps.js

Lines changed: 53 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! angular-google-maps 2.1.5 2015-08-09
1+
/*! angular-google-maps 2.1.5 2015-08-16
22
* AngularJS directives for Google Maps
33
* git: https://github.com/angular-ui/angular-google-maps.git
44
*/
@@ -827,23 +827,23 @@ Nicholas McCready - https://twitter.com/nmccready
827827
}).call(this);
828828
;(function() {
829829
angular.module('uiGmapgoogle-maps.directives.api.utils').service('uiGmapFitHelper', [
830-
'uiGmapLogger', 'uiGmap_async', function($log, _async) {
830+
'uiGmapLogger', function($log) {
831831
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)) {
835835
bounds = new google.maps.LatLngBounds();
836836
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;
844842
}
845-
};
846-
})(this));
843+
point = _.isFunction(markerOrPoint.getPosition) ? markerOrPoint.getPosition() : markerOrPoint;
844+
}
845+
bounds.extend(point);
846+
}
847847
if (everSet) {
848848
return gMap.fitBounds(bounds);
849849
}
@@ -1097,16 +1097,6 @@ Nicholas McCready - https://twitter.com/nmccready
10971097
}
10981098
return result;
10991099
},
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-
},
11101100
getPath: function(object, key) {
11111101
var obj;
11121102
if ((key == null) || !_.isString(key)) {
@@ -2858,7 +2848,7 @@ Nicholas McCready - https://twitter.com/nmccready
28582848

28592849
BasePolyChildModel.include(GmapUtil);
28602850

2861-
function BasePolyChildModel(scope, attrs, map, defaults, model) {
2851+
function BasePolyChildModel(scope, attrs, map, defaults, model, gObjectChangeCb) {
28622852
var create;
28632853
this.scope = scope;
28642854
this.attrs = attrs;
@@ -2884,27 +2874,25 @@ Nicholas McCready - https://twitter.com/nmccready
28842874
};
28852875
create = (function(_this) {
28862876
return function() {
2887-
var maybeCachedEval, pathPoints;
2877+
var maybeCachedEval;
28882878
if (_this.isDragging) {
28892879
return;
28902880
}
2891-
pathPoints = _this.convertPathPoints(_this.scope.path);
2881+
_this.pathPoints = _this.convertPathPoints(_this.scope.path);
28922882
if (_this.gObject != null) {
28932883
_this.clean();
28942884
}
28952885
if (_this.scope.model != null) {
28962886
maybeCachedEval = _this.scope;
28972887
}
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));
29002890
}
29012891
if (_this.gObject) {
2902-
if (_this.scope.fit) {
2903-
_this.extendMapBounds(_this.map, pathPoints);
2904-
}
29052892
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();
29082896
}
29092897
});
29102898
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
39363924
hasProp = {}.hasOwnProperty;
39373925

39383926
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) {
39403928
return function(IPoly, PolyChildModel, gObjectName) {
39413929
var BasePolysParentModel;
39423930
return BasePolysParentModel = (function(superClass) {
@@ -3949,6 +3937,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
39493937
this.attrs = attrs;
39503938
this.gMap = gMap1;
39513939
this.defaults = defaults;
3940+
this.maybeFit = bind(this.maybeFit, this);
39523941
this.createChild = bind(this.createChild, this);
39533942
this.pieceMeal = bind(this.pieceMeal, this);
39543943
this.createAllNew = bind(this.createAllNew, this);
@@ -4075,15 +4064,17 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
40754064
return maybeCanceled = canceledMsg;
40764065
}), (function(_this) {
40774066
return function() {
4078-
return _async.each(scope.models, function(model) {
4067+
return _async.map(scope.models, function(model) {
40794068
var child;
40804069
child = _this.createChild(model, _this.gMap);
40814070
if (maybeCanceled) {
40824071
$log.debug('createNew should fall through safely');
40834072
child.isEnabled = false;
40844073
}
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);
40874078
return _this.firstTime = false;
40884079
});
40894080
};
@@ -4127,7 +4118,9 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
41274118
}
41284119
_this.createChild(modelToAdd, _this.gMap);
41294120
return maybeCanceled;
4130-
}, _async.chunkSizeFrom(scope.chunk));
4121+
}, _async.chunkSizeFrom(scope.chunk)).then(function() {
4122+
return _this.maybeFit();
4123+
});
41314124
});
41324125
};
41334126
})(this));
@@ -4149,7 +4142,11 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
41494142
};
41504143
})(this), true);
41514144
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));
41534150
if (model[this.idKey] == null) {
41544151
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.");
41554152
return;
@@ -4158,6 +4155,18 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
41584155
return child;
41594156
};
41604157

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+
41614170
return BasePolysParentModel;
41624171

41634172
})(ModelKey);
@@ -6809,7 +6818,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
68096818
hasProp = {}.hasOwnProperty;
68106819

68116820
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) {
68136822
var Polygon;
68146823
return Polygon = (function(superClass) {
68156824
extend(Polygon, superClass);
@@ -6848,7 +6857,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
68486857
hasProp = {}.hasOwnProperty;
68496858

68506859
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) {
68526861
var Polygons;
68536862
return Polygons = (function(superClass) {
68546863
extend(Polygons, superClass);
@@ -6887,7 +6896,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
68876896
hasProp = {}.hasOwnProperty;
68886897

68896898
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) {
68916900
var Polyline;
68926901
return Polyline = (function(superClass) {
68936902
extend(Polyline, superClass);
@@ -6921,7 +6930,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
69216930
hasProp = {}.hasOwnProperty;
69226931

69236932
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) {
69256934
var Polylines;
69266935
return Polylines = (function(superClass) {
69276936
extend(Polylines, superClass);

0 commit comments

Comments
 (0)