Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/angular-google-staticmaps.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* angular-google-staticmaps <%= pkg.version %>
* angular-google-staticmaps 0.0.1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how change it, revert this line....

* Pascal Hartig, weluse GmbH, http://weluse.de/
* License: MIT
*/
Expand All @@ -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) {
Expand All @@ -23,7 +23,7 @@
});
};

this.buildSourceString = function buildSourceString(attrs, markers) {
this.buildSourceString = function buildSourceString(attrs, markers, apiKey) {
var markerStrings;

if (markers) {
Expand All @@ -40,6 +40,10 @@
}).join('&');
}

if(attr === 'key'){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you maintain the existing code style please?

return 'key=' + apiKey;
}

if (attr[0] !== '$' && attr !== 'alt') {
return encodeURIComponent(attr) + '=' + encodeURIComponent(attrs[attr]);
}
Expand Down Expand Up @@ -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.');
Expand All @@ -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);
}
};
});
Expand Down