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

Commit 4d3f05c

Browse files
committed
rebuild
1 parent 7e3df15 commit 4d3f05c

11 files changed

+385
-43
lines changed

dist/angular-google-maps.js

Lines changed: 158 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4816,30 +4816,38 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
48164816
MapTypeParentModel = (function(superClass) {
48174817
extend(MapTypeParentModel, superClass);
48184818

4819-
function MapTypeParentModel(scope, element, attrs, gMap, $log) {
4819+
function MapTypeParentModel(scope, element, attrs, gMap, $log, childModel, propMap) {
4820+
var watchChildModelOptions, watchChildModelShow, watchOptions, watchShow;
48204821
this.scope = scope;
48214822
this.element = element;
48224823
this.attrs = attrs;
48234824
this.gMap = gMap;
48244825
this.$log = $log != null ? $log : Logger;
4826+
this.childModel = childModel;
4827+
this.propMap = propMap;
4828+
this.refreshShown = bind(this.refreshShown, this);
48254829
this.hideOverlay = bind(this.hideOverlay, this);
48264830
this.showOverlay = bind(this.showOverlay, this);
48274831
this.refreshMapType = bind(this.refreshMapType, this);
48284832
this.createMapType = bind(this.createMapType, this);
4829-
if (this.attrs.options == null) {
4833+
if (this.scope.options == null) {
48304834
this.$log.info('options attribute for the map-type directive is mandatory. Map type creation aborted!!');
48314835
return;
48324836
}
48334837
this.id = this.gMap.overlayMapTypesCount = this.gMap.overlayMapTypesCount + 1 || 0;
48344838
this.doShow = true;
48354839
this.createMapType();
4836-
if (angular.isDefined(this.attrs.show)) {
4837-
this.doShow = this.scope.show;
4838-
}
4840+
this.refreshShown();
48394841
if (this.doShow && (this.gMap != null)) {
48404842
this.showOverlay();
48414843
}
4842-
this.scope.$watch('show', (function(_this) {
4844+
watchChildModelShow = (function(_this) {
4845+
return function() {
4846+
return _this.childModel[_this.attrs.show];
4847+
};
4848+
})(this);
4849+
watchShow = this.childModel ? watchChildModelShow : 'show';
4850+
this.scope.$watch(watchShow, (function(_this) {
48434851
return function(newValue, oldValue) {
48444852
if (newValue !== oldValue) {
48454853
_this.doShow = newValue;
@@ -4850,8 +4858,14 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
48504858
}
48514859
}
48524860
};
4853-
})(this), true);
4854-
this.scope.$watchCollection('options', (function(_this) {
4861+
})(this));
4862+
watchChildModelOptions = (function(_this) {
4863+
return function() {
4864+
return _this.childModel[_this.attrs.options];
4865+
};
4866+
})(this);
4867+
watchOptions = this.childModel ? watchChildModelOptions : 'options';
4868+
this.scope.$watchCollection(watchOptions, (function(_this) {
48554869
return function(newValue, oldValue) {
48564870
var different, mapTypeProps;
48574871
if (!_.isEqual(newValue, oldValue)) {
@@ -4883,21 +4897,28 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
48834897
}
48844898

48854899
MapTypeParentModel.prototype.createMapType = function() {
4886-
if (this.scope.options.getTile != null) {
4887-
this.mapType = this.scope.options;
4888-
} else if (this.scope.options.getTileUrl != null) {
4889-
this.mapType = new google.maps.ImageMapType(this.scope.options);
4900+
var id, idAttr, mapType;
4901+
mapType = this.childModel ? (this.attrs.options ? this.childModel[this.attrs.options] : this.childModel) : this.scope.options;
4902+
if (mapType.getTile != null) {
4903+
this.mapType = mapType;
4904+
} else if (mapType.getTileUrl != null) {
4905+
this.mapType = new google.maps.ImageMapType(mapType);
48904906
} else {
48914907
this.$log.info('options should provide either getTile or getTileUrl methods. Map type creation aborted!!');
48924908
return;
48934909
}
4894-
if (this.attrs.id && this.scope.id) {
4895-
this.gMap.mapTypes.set(this.scope.id, this.mapType);
4910+
idAttr = this.attrs.id ? (this.childModel ? this.attrs.id : 'id') : void 0;
4911+
id = idAttr ? (this.childModel ? this.childModel[idAttr] : this.scope[idAttr]) : void 0;
4912+
if (id) {
4913+
this.gMap.mapTypes.set(id, this.mapType);
48964914
if (!angular.isDefined(this.attrs.show)) {
48974915
this.doShow = false;
48984916
}
48994917
}
4900-
return this.mapType.layerId = this.id;
4918+
this.mapType.layerId = this.id;
4919+
if (this.childModel && angular.isDefined(this.scope.index)) {
4920+
return this.propMap.put(this.mapType.layerId, this.scope.index);
4921+
}
49014922
};
49024923

49034924
MapTypeParentModel.prototype.refreshMapType = function() {
@@ -4910,7 +4931,31 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
49104931
};
49114932

49124933
MapTypeParentModel.prototype.showOverlay = function() {
4913-
return this.gMap.overlayMapTypes.push(this.mapType);
4934+
var found;
4935+
if (angular.isDefined(this.scope.index)) {
4936+
found = false;
4937+
if (this.gMap.overlayMapTypes.getLength()) {
4938+
this.gMap.overlayMapTypes.forEach((function(_this) {
4939+
return function(mapType, index) {
4940+
var layerIndex;
4941+
if (!found) {
4942+
layerIndex = _this.propMap.get(mapType.layerId.toString());
4943+
if (layerIndex > _this.scope.index || !angular.isDefined(layerIndex)) {
4944+
found = true;
4945+
_this.gMap.overlayMapTypes.insertAt(index, _this.mapType);
4946+
}
4947+
}
4948+
};
4949+
})(this));
4950+
if (!found) {
4951+
return this.gMap.overlayMapTypes.push(this.mapType);
4952+
}
4953+
} else {
4954+
return this.gMap.overlayMapTypes.push(this.mapType);
4955+
}
4956+
} else {
4957+
return this.gMap.overlayMapTypes.push(this.mapType);
4958+
}
49144959
};
49154960

49164961
MapTypeParentModel.prototype.hideOverlay = function() {
@@ -4926,13 +4971,62 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
49264971
})(this));
49274972
};
49284973

4974+
MapTypeParentModel.prototype.refreshShown = function() {
4975+
return this.doShow = angular.isDefined(this.attrs.show) ? (this.childModel ? this.childModel[this.attrs.show] : this.scope.show) : true;
4976+
};
4977+
49294978
return MapTypeParentModel;
49304979

49314980
})(BaseObject);
49324981
return MapTypeParentModel;
49334982
}
49344983
]);
49354984

4985+
}).call(this);
4986+
;(function() {
4987+
var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
4988+
hasProp = {}.hasOwnProperty;
4989+
4990+
angular.module('uiGmapgoogle-maps.directives.api.models.parent').factory('uiGmapMapTypesParentModel', [
4991+
'uiGmapBaseObject', 'uiGmapLogger', 'uiGmapMapTypeParentModel', 'uiGmapPropMap', function(BaseObject, Logger, MapTypeParentModel, PropMap) {
4992+
var MapTypesParentModel;
4993+
MapTypesParentModel = (function(superClass) {
4994+
extend(MapTypesParentModel, superClass);
4995+
4996+
function MapTypesParentModel(scope, element, attrs, gMap, $log) {
4997+
var pMap;
4998+
this.scope = scope;
4999+
this.element = element;
5000+
this.attrs = attrs;
5001+
this.gMap = gMap;
5002+
this.$log = $log != null ? $log : Logger;
5003+
if (this.attrs.mapTypes == null) {
5004+
this.$log.info('layers attribute for the map-types directive is mandatory. Map types creation aborted!!');
5005+
return;
5006+
}
5007+
pMap = new PropMap;
5008+
this.scope.mapTypes.forEach((function(_this) {
5009+
return function(l, i) {
5010+
var childScope, mockAttr;
5011+
mockAttr = {
5012+
options: _this.scope.options,
5013+
show: _this.scope.show,
5014+
refresh: _this.scope.refresh
5015+
};
5016+
childScope = _this.scope.$new();
5017+
childScope.index = i;
5018+
new MapTypeParentModel(childScope, null, mockAttr, _this.gMap, _this.$log, l, pMap);
5019+
};
5020+
})(this));
5021+
}
5022+
5023+
return MapTypesParentModel;
5024+
5025+
})(BaseObject);
5026+
return MapTypesParentModel;
5027+
}
5028+
]);
5029+
49365030
}).call(this);
49375031
;
49385032
/*global _:true,angular:true, */
@@ -7886,6 +7980,54 @@ This directive creates a new scope.
78867980
}
78877981
]);
78887982

7983+
}).call(this);
7984+
;
7985+
/*
7986+
Map Layers directive
7987+
7988+
This directive is used to create any type of Layer from the google maps sdk.
7989+
This directive creates a new scope.
7990+
*/
7991+
7992+
(function() {
7993+
var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
7994+
7995+
angular.module('uiGmapgoogle-maps').directive("uiGmapMapTypes", [
7996+
"$timeout", "uiGmapLogger", "uiGmapMapTypesParentModel", function($timeout, Logger, MapTypesParentModel) {
7997+
var MapTypes;
7998+
MapTypes = (function() {
7999+
function MapTypes() {
8000+
this.link = bind(this.link, this);
8001+
this.$log = Logger;
8002+
this.restrict = "EMA";
8003+
this.require = '^' + 'uiGmapGoogleMap';
8004+
this.priority = -1;
8005+
this.transclude = true;
8006+
this.template = '<span class=\"angular-google-map-layers\" ng-transclude></span>';
8007+
this.scope = {
8008+
mapTypes: "=mapTypes",
8009+
show: "=show",
8010+
options: "=options",
8011+
refresh: "=refresh",
8012+
id: "=idKey"
8013+
};
8014+
}
8015+
8016+
MapTypes.prototype.link = function(scope, element, attrs, mapCtrl) {
8017+
return mapCtrl.getScope().deferred.promise.then((function(_this) {
8018+
return function(map) {
8019+
return new MapTypesParentModel(scope, element, attrs, map);
8020+
};
8021+
})(this));
8022+
};
8023+
8024+
return MapTypes;
8025+
8026+
})();
8027+
return new MapTypes();
8028+
}
8029+
]);
8030+
78898031
}).call(this);
78908032
;
78918033
/*

dist/angular-google-maps.min.js

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

0 commit comments

Comments
 (0)