var ngMap=angular.module("ngMap",[]);ngMap.service("Attr2Options",["$parse","NavigatorGeolocation","GeoCoder",function($parse,NavigatorGeolocation,GeoCoder){var SPECIAL_CHARS_REGEXP=/([\:\-\_]+(.))/g,MOZ_HACK_REGEXP=/^moz([A-Z])/,orgAttributes=function(e){e.length>0&&(e=e[0]);for(var t={},n=0;n0;for(var eventName in events)eventName&&google.maps.event.addListener(infoWindow,eventName,events[eventName]);var template=element.html().trim();if(1!=angular.element(template).length)throw"info-window working as a template must have a container";return infoWindow.__template=template.replace(/\s?ng-non-bindable[='"]+/,""),infoWindow.__compile=function(e){var t=$compile(infoWindow.__template)(e);e.$apply(),infoWindow.setContent(t[0])},infoWindow.__eval=function(event){var template=infoWindow.__template,_this=this;return template=template.replace(/{{(event|this)[^;\}]+}}/g,function(match){var expression=match.replace(/[{}]/g,"").replace("this.","_this.");return eval(expression)})},infoWindow};return{restrict:"E",require:"^map",link:function(e,t,n,o){t.css("display","none");var a=parser.orgAttributes(t),r=parser.filter(n),i=parser.getOptions(r,e),s=parser.getEvents(e,r),p=getInfoWindow(i,s,t);o.addObject("infoWindows",p),parser.observeAttrSetObj(a,n,p),p.visible&&e.$on("mapInitialized",function(t,n){$timeout(function(){p.__template=p.__eval.apply(this,[t]),p.__compile(e),p.map=n,p.position&&p.open(n)})}),p.visibleOnMarker&&e.$on("mapInitialized",function(t,n){$timeout(function(){var o=p.visibleOnMarker,a=n.markers[o];if(!a)throw"Invalid marker id";p.__template=p.__eval.apply(this,[t]),p.__compile(e),p.open(n,a)})}),e.showInfoWindow=e.showInfoWindow||function(t,n,a){var r=o.map.infoWindows[n],i=r.__template;r.__template=r.__eval.apply(this,[t]),r.__compile(e),a?r.open(o.map,a):this.getPosition?r.open(o.map,this):r.open(o.map),r.__template=i},e.hideInfoWindow=e.hideInfoWindow||function(t,n){var a=o.map.infoWindows[n];a.__template=a.__eval.apply(this,[t]),a.__compile(e),a.close()}}}}]),ngMap.directive("kmlLayer",["Attr2Options",function(e){var t=e,n=function(e,t){var n=new google.maps.KmlLayer(e);for(var o in t)google.maps.event.addListener(n,o,t[o]);return n};return{restrict:"E",require:"^map",link:function(e,o,a,r){var i=t.orgAttributes(o),s=t.filter(a),p=t.getOptions(s),c=t.getEvents(e,s),l=n(p,c);r.addObject("kmlLayers",l),t.observeAttrSetObj(i,a,l)}}}]),ngMap.directive("mapData",["Attr2Options",function(e){var t=e;return{restrict:"E",require:"^map",link:function(e,n,o){var a=t.filter(o),r=t.getOptions(a),i=t.getEvents(e,a,i);e.$on("mapInitialized",function(t,n){for(var o in r)if(o){var a=r[o];"function"==typeof e[a]?n.data[o](e[a]):n.data[o](a)}for(var s in i)i[s]&&n.data.addListener(s,i[s])})}}}]),ngMap.directive("mapLazyLoad",["$compile","$timeout",function(e,t){"use strict";var n={compile:function(n,o){!o.mapLazyLoad&&void 0;var a=n.html(),r=o.mapLazyLoad;return document.querySelector('script[src="'+r+'"]')?!1:(n.html(""),{pre:function(n,o){window.lazyLoadCallback=function(){t(function(){o.html(a),e(o.contents())(n)},100)};var i=document.createElement("script");i.src=r+"?callback=lazyLoadCallback",document.body.appendChild(i)}})}};return n}]),ngMap.directive("mapType",["Attr2Options","$window",function(e,t){return{restrict:"E",require:"^map",link:function(e,n,o,a){var r,i=o.name;if(!i)throw"invalid map-type name";if(o.object){var s=e[o.object]?e:t;r=s[o.object],"function"==typeof r&&(r=new r)}if(!r)throw"invalid map-type object";e.$on("mapInitialized",function(e,t){t.mapTypes.set(i,r)}),a.addObject("mapTypes",r)}}}]),ngMap.directive("map",["Attr2Options","$timeout",function(e,t){function n(e,t){if(e.currentStyle)var n=e.currentStyle[t];else if(window.getComputedStyle)var n=document.defaultView.getComputedStyle(e,null).getPropertyValue(t);return n}var o=e;return{restrict:"AE",controller:ngMap.MapController,link:function(a,r,i,s){var p=o.orgAttributes(r);a.google=google;var c=document.createElement("div");c.style.width="100%",c.style.height="100%",r.prepend(c),"block"!=n(r[0],"display")&&r.css("display","block"),n(r[0],"height").match(/^(0|auto)/)&&r.css("height","300px");var l=function(n,r){var l=new google.maps.Map(c,{});l.markers={},l.shapes={},t(function(){google.maps.event.trigger(l,"resize")}),n.zoom=n.zoom||15;var u=n.center;u?u instanceof google.maps.LatLng||(delete n.center,e.setDelayedGeoLocation(l,"setCenter",u,{fallbackLocation:g.geoFallbackCenter})):n.center=new google.maps.LatLng(0,0),l.setOptions(n);for(var m in r)m&&google.maps.event.addListener(l,m,r[m]);o.observeAttrSetObj(p,i,l),s.map=l,s.addObjects(s._objects),a.map=l,a.map.scope=a,a.$emit("mapInitialized",l),a.maps=a.maps||{},a.maps[g.id||Object.keys(a.maps).length]=l,a.$emit("mapsInitialized",a.maps)},u=o.filter(i),g=o.getOptions(u,a),m=o.getControlOptions(u),v=angular.extend(g,m),d=o.getEvents(a,u);i.initEvent?a.$on(i.initEvent,function(){!s.map&&l(v,d)}):l(v,d)}}}]),ngMap.MapController=function(){this.map=null,this._objects=[],this.addMarker=function(e){if(this.map){this.map.markers=this.map.markers||{},e.setMap(this.map),e.centered&&this.map.setCenter(e.position);var t=Object.keys(this.map.markers).length;this.map.markers[e.id||t]=e}else this._objects.push(e)},this.addShape=function(e){if(this.map){this.map.shapes=this.map.shapes||{},e.setMap(this.map);var t=Object.keys(this.map.shapes).length;this.map.shapes[e.id||t]=e}else this._objects.push(e)},this.addObject=function(e,t){if(this.map){this.map[e]=this.map[e]||{};var n=Object.keys(this.map[e]).length;this.map[e][t.id||n]=t,"infoWindows"!=e&&t.setMap&&t.setMap(this.map)}else t.groupName=e,this._objects.push(t)},this.addObjects=function(e){for(var t=0;t0;for(var s in n)s&&google.maps.event.addListener(o,s,n[s]);return o};return{restrict:"E",require:"^map",link:function(e,o,a,r){var i=t.orgAttributes(o),s=t.filter(a),p=t.getOptions(s,e),c=t.getEvents(e,s);o.bind("$destroy",function(){var e=l.map.markers;for(var t in e)e[t]==l&&delete e[t];l.setMap(null)});var l=n(p,c);r.addMarker(l),t.observeAttrSetObj(i,a,l)}}}]),ngMap.directive("overlayMapType",["Attr2Options","$window",function(e,t){return{restrict:"E",require:"^map",link:function(e,n,o,a){var r,i=o.initMethod||"insertAt";if(o.object){var s=e[o.object]?e:t;r=s[o.object],"function"==typeof r&&(r=new r)}if(!r)throw"invalid map-type object";e.$on("mapInitialized",function(e,t){if("insertAt"==i){var n=parseInt(o.index,10);t.overlayMapTypes.insertAt(n,r)}else"push"==i&&t.overlayMapTypes.push(r)}),a.addObject("overlayMapTypes",r)}}}]),ngMap.directive("shape",["Attr2Options",function(e){var t=e,n=function(e){return new google.maps.LatLngBounds(e[0],e[1])},o=function(e,o){var a,r=e.name;if(delete e.name,e.icons)for(var i=0;i