From 022e0ba47c28d211b926db1470590827b6b0ba70 Mon Sep 17 00:00:00 2001 From: Alfredo de la Calle Date: Thu, 25 Jun 2015 10:36:46 +0200 Subject: [PATCH 1/2] Use an Google Map API Key Added an optional attribute 'Key' in a directive to tracking with Gmap API Key --- src/angular-google-staticmaps.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/angular-google-staticmaps.js b/src/angular-google-staticmaps.js index 8ff96b5..5f2e0cd 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 */ @@ -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); } }; }); From a534b796a146e5a408f0e6df144767cfc267fbab Mon Sep 17 00:00:00 2001 From: Alfredo de la Calle Date: Thu, 2 Jul 2015 12:50:12 +0200 Subject: [PATCH 2/2] Add icon parameter Added icon parameter to accept a absolute path to pin image map --- src/angular-google-staticmaps.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/angular-google-staticmaps.js b/src/angular-google-staticmaps.js index 5f2e0cd..71b4710 100644 --- a/src/angular-google-staticmaps.js +++ b/src/angular-google-staticmaps.js @@ -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) {