/** * @ngdoc directive * @name map-type * @param Attr2MapOptions {service} * convert html attribute to Google map api options * @description * Requires: map directive * Restrict To: Element * * @example * Example: * * * * */ (function() { 'use strict'; angular.module('ngMap').directive('mapType', ['$parse', 'NgMap', function($parse, NgMap) { return { restrict: 'E', require: ['?^map','?^ngMap'], link: function(scope, element, attrs, mapController) { mapController = mapController[0]||mapController[1]; var mapTypeName = attrs.name, mapTypeObject; if (!mapTypeName) { throw "invalid map-type name"; } mapTypeObject = $parse(attrs.object)(scope); if (!mapTypeObject) { throw "invalid map-type object"; } NgMap.getMap().then(function(map) { map.mapTypes.set(mapTypeName, mapTypeObject); }); mapController.addObject('mapTypes', mapTypeObject); } }; // return }]); })();