var VWA_GMap={map:null,vwaMarker:"",_geocoder:null,_bLastMarker:false,infoWindow:null,latlngbounds:null,gmarkers:null,settings:null,_onload:[],_loaded:false,SelectedVwaMarker:null,get_geocoder:function(){if(!this._geocoder){this._geocoder=new google.maps.Geocoder()}return this._geocoder},map_load:function(b,a){this.infoWindow=null;this._geocoder=null;this.settings=b;this.gmarkers=[];if(this.map){this.map=null}if(!this.map){var c={zoom:9,center:new google.maps.LatLng(52,6),mapTypeId:google.maps.MapTypeId.ROADMAP,navigationControl:(this.settings.control!="None"),mapTypeControl:true,scaleControl:true};this.map=new google.maps.Map(document.getElementById(a),c)}this.latlngbounds=new google.maps.LatLngBounds();while(this.settings.markers.length>0){this.vwa_addMarker(this.map,this.settings.markers.pop())}this.map_load_done()},vwa_addMarker:function(c,a,d){if(a.point){var b=new google.maps.LatLng(a.point.latitude,a.point.longitude);a.gMarker=this.vwa_addMarker2(b,a)}},vwa_addMarker2:function(e,a){if(!e){return null}var c;if(a.icon){var b=new google.maps.MarkerImage(a.icon.image,new google.maps.Size(a.icon.iconSize.width,a.icon.iconSize.height),new google.maps.Point(a.icon.infoWindowAnchor.x,a.icon.infoWindowAnchor.y),new google.maps.Point(a.icon.iconAnchor.x,a.icon.iconAnchor.y));c={icon:b}}else{c={}}c.title=a.title;c.map=this.map;c.position=e;var d=new google.maps.Marker(c);this.gmarkers.push(d);d.__vwaHtml=a.html;this.lastGMarker=d;google.maps.event.addListener(d,"click",function(f,g){VWA_GMap.OpenInfoWindow(this)});if(a.Selected){this.SelectedVwaMarker=a}this.latlngbounds.extend(e);return d},get_MarkersPlaced:function(){return this.gmarkers.length},add_onload:function(a){if(typeof(a)!="function"){return}if(this._loaded){a(this)}else{this._onload.push(a)}},map_load_done:function(){if(this.settings.EnableClustering){var c={gridSize:this.settings.ClusteringSize,maxZoom:this.settings.ClusteringMaxZoom};this.cluster=new MarkerClusterer(this.map,this.gmarkers,c)}while(this._onload.length>0){var b=this._onload.pop()(this)}if(VWA_GMap.SelectedVwaMarker){VWA_GMap.OpenInfoWindow(VWA_GMap.SelectedVwaMarker.gMarker);this.map.setCenter(this.SelectedVwaMarker.gMarker.getPosition());this.map.setZoom(17)}else{if(this.get_MarkersPlaced()>1){this.map.fitBounds(this.latlngbounds)}if(this.get_MarkersPlaced()==1&&this.lastGMarker&&this.lastGMarker.getPosition){this.map.setCenter(this.lastGMarker.getPosition())}}this._loaded=true}};VWA_GMap.OpenInfoWindow=function(a,b){if(!VWA_GMap.infoWindow){VWA_GMap.infoWindow=new google.maps.InfoWindow();google.maps.event.addListener(VWA_GMap.map,"click",function(){VWA_GMap.infoWindow.close()})}VWA_GMap.infoWindow.setContent(a.__vwaHtml);VWA_GMap.infoWindow.open(VWA_GMap.map,a)};VWA_GMap.getCoordinate=function(f,e,g,c){var b="";if(typeof(e)=="string"){b=e}else{if(e&&e.value){b=e.value}}if(b.length==0){alert(translate.getValue("STORE_EMPTY"));return false}var a=this.get_geocoder();if(!a){alert("Geen geocoder object");return false}var d={address:b,language:sLangCode,bounds:this.latlngbounds,region:null};if(c&&c.length>0){d.region=c}a.geocode(d,function(j,h){if(!j||h==google.maps.GeocoderStatus.ZERO_RESULTS){alert(b+" "+translate.getValue("COM_NOT_FOUND"))}else{if(h==google.maps.GeocoderStatus.OK){var i=j[0];__doPostBack(g,i.geometry.location.lng()+"_"+i.geometry.location.lat()+"_"+i.formatted_address)}else{alert(b+" "+translate.getValue("COM_NOT_FOUND"))}}});return false};VWA_GMap.GoToRoute=function(c,a){directionsService=new google.maps.DirectionsService();directionsDisplay=new google.maps.DirectionsRenderer();directionsDisplay.setMap(this.map);if(a&&$get(a)){directionsDisplay.setPanel($get(a))}var b={origin:c,destination:this.lastGMarker.getPosition(),travelMode:google.maps.DirectionsTravelMode.DRIVING,provideRouteAlternatives:true};directionsService.route(b,function(d,e){if(e==google.maps.DirectionsStatus.OK){directionsDisplay.setDirections(d);window.setTimeout(setHeight,50)}});ModalPopupClose()};if(typeof(Sys)!=="undefined"){Sys.Application.notifyScriptLoaded()};
