forked from passy/angular-google-staticmaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-google-staticmaps.min.js
6 lines (6 loc) · 1.36 KB
/
angular-google-staticmaps.min.js
1
2
3
4
5
6
/*!
* angular-google-staticmaps 0.3.1
* Pascal Hartig, weluse GmbH, http://weluse.de/
* License: MIT
*/
!function(){"use strict";angular.module("wu.staticGmap",[]).controller("StaticGmapCtrl",function(){var a="https://maps.googleapis.com/maps/api/staticmap?",b=["color","label","size","icon"];this.makeMarkerStrings=function(a){return a.map(function(a){var c=Object.keys(a).map(function(c){return b.indexOf(c)>-1?c+":"+a[c]+"|":void 0}).join("");return c+a.coords.join(",")})},this.buildSourceString=function(b,c){var d;c&&(angular.isArray(c)||(c=[c]),d=this.makeMarkerStrings(c));var e=Object.keys(b).map(function(a){return"markers"===a&&d?Object.keys(d).map(function(a){return"markers="+encodeURIComponent(d[a])}).join("&"):"$"!==a[0]&&"alt"!==a?encodeURIComponent(a)+"="+encodeURIComponent(b[a]):void 0});return a+e.reduce(function(a,b){return a?void 0!==b?a+"&"+b:a:b},"")}}).directive("staticGmap",function(a){return{template:'<img alt="Google Map">',replace:!0,restrict:"E",controller:"StaticGmapCtrl",scope:!0,link:function(b,c,d,e){var f=c[0],g=a(d.markers)(b);if(!d.sensor)throw new Error("The `sensor` attribute is required.");if(!d.size)throw new Error("The `size` attribute is required.");var h=d.size.split("x");if(2!==h.length)throw new Error("Size must be specified as `wxh`.");f.width=parseInt(h[0],10),f.height=parseInt(h[1],10),f.src=e.buildSourceString(d,g)}}})}();