(function(){"use strict";var o={api:"//maps.googleapis.com/maps/api/js?callback=__googlemapsInitialize&sensor=false"};u8.Base.Geolocation.GoogleMapsProvider=function(o){$.extend(this,u8.Base.Geolocation.GoogleMapsProvider.defaults,o);this.elWindow=this.elWindow||$w("top")};u8.Base.Geolocation.GoogleMapsProvider.defaults={mapType:"GoogleMap"};$.extend(u8.Base.Geolocation.GoogleMapsProvider.prototype,{load:function(e){var a=this;var s=this.elWindow;if(!s.google||!s.google.maps){var i=$p(s);if(i["GoogleMaps.onLoad"]){i["GoogleMaps.onLoad"].bind(r)}else{i["GoogleMaps.onLoad"]=new u8.Base.Event(r);s.__googlemapsInitialize=function(){i["GoogleMaps.onLoad"].raise();delete i["GoogleMaps.onLoad"];delete s.__googlemapsInitialize};var l=o.api+(this.apiKey?"&key="+encodeURIComponent(this.apiKey):"");i.factory.scripts.load(l)}}else{r()}function r(){var o=s.google&&s.google.maps;a.api=o;if(o){e(a,{provider:a})}else{e(a,{error:{message:"Failed to load google maps API."}})}}},geocode:function(o,a){var s=o&&o.address;var i=s.queryString;if(!i){return a(this,{error:{message:"Failed to create queryString."}})}var l=this._getGoogleMaps();if(!l){return a(this,{error:{message:"Geocode failed for the following reason: The google maps API failed to load."}})}if(!s){return a(this,{})}u8.log.info("Geocoding address '"+s+"'.");var r=this;var t=new l.Geocoder;t.geocode({address:i},function(s,i){if(i==l.GeocoderStatus.OK){var t=s[0].geometry.location;a(r,{location:e(t.lat(),t.lng()),address:o.address})}else if(i==l.GeocoderStatus.ZERO_RESULTS){a(r,{})}else{a(r,{error:{message:"Geocode failed for the following reason: "+i}})}})},_getGoogleMaps:function(){return this.elWindow.google&&this.elWindow.google.maps}});function e(o,e){return new u8.Base.Geolocation.Location({lat:o,lng:e})}u8.Base.Geolocation.GoogleMapsProvider.makeClass({name:"GoogleMapsProvider"})})();