diff --git a/src/angular-google-staticmaps.js b/src/angular-google-staticmaps.js index 8ff96b5..71b4710 100644 --- a/src/angular-google-staticmaps.js +++ b/src/angular-google-staticmaps.js @@ -1,5 +1,5 @@ /*! - * angular-google-staticmaps <%= pkg.version %> + * angular-google-staticmaps 0.0.1 * Pascal Hartig, weluse GmbH, http://weluse.de/ * License: MIT */ @@ -9,7 +9,7 @@ angular.module('wu.staticGmap', []) .controller('StaticGmapCtrl', function () { var BASE_URL = '//maps.googleapis.com/maps/api/staticmap?'; - var STYLE_ATTRIBUTES = ['color', 'label', 'size']; + var STYLE_ATTRIBUTES = ['color', 'icon', 'label', 'size']; this.makeMarkerStrings = function makeMarkerStrings(markers) { return markers.map(function (marker) { @@ -23,7 +23,7 @@ }); }; - this.buildSourceString = function buildSourceString(attrs, markers) { + this.buildSourceString = function buildSourceString(attrs, markers, apiKey) { var markerStrings; if (markers) { @@ -40,6 +40,10 @@ }).join('&'); } + if(attr === 'key'){ + return 'key=' + apiKey; + } + if (attr[0] !== '$' && attr !== 'alt') { return encodeURIComponent(attr) + '=' + encodeURIComponent(attrs[attr]); } @@ -68,7 +72,9 @@ link: function postLink(scope, element, attrs, ctrl) { var el = element[0]; - var markers = $parse(attrs.markers)(scope); + var markers = $parse(attrs.markers)(scope), + apiKey = $parse(attrs.key)(scope); + if (!attrs.sensor) { throw new Error('The `sensor` attribute is required.'); @@ -85,7 +91,7 @@ el.width = parseInt(sizeBits[0], 10); el.height = parseInt(sizeBits[1], 10); - el.src = ctrl.buildSourceString(attrs, markers); + el.src = ctrl.buildSourceString(attrs, markers, apiKey); } }; });