﻿
(function(){if(typeof BA==='undefined'){BA={};}
if(typeof BA.Google==='undefined'){BA.Google={};}
if(typeof BA.Google.GoogleMap==='undefined'){BA.Google.GoogleMap={};}
$j.extend(BA.Google.GoogleMap,{markersArray:[],map:null,cityLatLng:null,maxZoom:11,generateMap:function(jWrapper,address,width,height,limitZoomLevel)
{jWrapper.css({'width':width+'px','height':height+'px','text-align':'center'});var map=new GMap2(jWrapper[0]);map=new GMap2(jWrapper[0]);var customUI=map.getDefaultUI();customUI.controls.scalecontrol=false;map.setUI(customUI);map.setCenter(new GLatLng(1,1),10);this.map=map;if(limitZoomLevel>11){this.maxZoom=limitZoomLevel;}},addMarker:function(latLng,data,callbackOnClick)
{if(this.map===null)alert("Enable to create marker because the map is not generated.");var customIcon=MapIconMaker.createMarkerIcon({width:36,height:32,primaryColor:"00F6FF"});var marker=new GMarker(latLng,customIcon);this.map.addOverlay(marker);this.markersArray.push(marker);GEvent.addListener(marker,'click',function()
{if(typeof callbackOnClick==='function')
{if(typeof data!=='undefined')callbackOnClick(marker,data);else callbackOnClick(marker);}});return marker;},addMarkerLatLng:function(latitude,longitude,data,callbackOnClick)
{var latLng=new GLatLng(latitude,longitude);this.addMarker(latLng,data,callbackOnClick);},clearMarkers:function()
{this.map.clearOverlays();this.markersArray.length=0;},autoZoom:function()
{if(this.map===null)alert("Enable to create marker because the map is not generated.");if(this.markersArray.length>0)
{var bounds=new GLatLngBounds();for(var i=0;i<this.markersArray.length;i++)
{bounds.extend(this.markersArray[i].getLatLng());}
var zoom=this.map.getBoundsZoomLevel(bounds);if(zoom>this.maxZoom){zoom=this.maxZoom;}
this.map.setCenter(bounds.getCenter(),zoom);}
else if(this.cityLatLng!==null)this.map.setCenter(this.cityLatLng,11);this.map.checkResize();},openInfoWindow:function(marker,tabsInfo,callbackOnOpen)
{tabs=[];for(var i=0;i<tabsInfo.length;i++)
{var infoWindowTab=new GInfoWindowTab(tabsInfo[i].title,tabsInfo[i].content);tabs.push(infoWindowTab);}
marker.openInfoWindowTabs(tabs);GEvent.addListener(marker,"infowindowopen",function()
{if(typeof callbackOnOpen==='function')
{callbackOnOpen();}});},openStreetView:function(marker,jwrapper,width,height)
{if(typeof width==='undefined'){width=1030;}
if(typeof height==='undefined'){height=530;}
jwrapper.css({'width':width+'px','height':height+'px'});var pano=new GStreetviewPanorama(jwrapper[0]);cameraOpts={yaw:10,pitch:0};pano.setLocationAndPOV(marker.getLatLng(),cameraOpts);GEvent.addListener(pano,"error",function(errorCode)
{if(errorCode==603){jwrapper.append("<strong>Error: Flash doesn't appear to be supported by your browser</strong>");return;}});var window=Cuke.Window.loadhtml(jwrapper.show(),{modal:true,resizable:false});window.show(width,height);}});})();
