GR_Maps=function(a){if(GBrowserIsCompatible()){this.markers=[];this.markCount=0;this.myMark=null;this.firstRun=true;this.map=new GMap2(document.getElementById("divGoogleMap"));this.map.setCenter(new GLatLng(52.1961148,5.277026),11);if(typeof a.scrollZoom!="undefined"){this.map.enableScrollWheelZoom()}if(typeof a.disableControls=="undefined"){this.map.addControl(new GLargeMapControl3D())}this.baseInfo={id:null,icon:null,link:null,mainpic:null,street:null,num:null,place:null,adres:null,price:null,postcode:null};this.curZoom=this.map.getZoom();this.xmlPath="../AllObjects.xml";this.iconType=1;if(typeof a.iconType!="undefined"){this.iconType=a.iconType}if(gr_objExists(document.getElementById("streetview"))){this.map.addControl(new StreetViewControl());this.streetview_init()}this.baseIcon=new GIcon(G_DEFAULT_ICON);this.baseIcon.image="http://websites.goesenroos.nl/general/images/aboverzicht/smartgmap/"+this.iconType+"/woning.png";this.baseIcon.shadow="http://websites.goesenroos.nl/general/images/aboverzicht/smartgmap/"+this.iconType+"/shadow-woning.png";this.baseIcon.iconSize=new GSize(22,30);this.baseIcon.shadowSize=new GSize(38,30);this.baseIcon.iconAnchor=new GPoint(11,15);this.baseIcon.infoWindowAnchor=new GPoint(11,15);this.kantIcon=new GIcon(G_DEFAULT_ICON);this.kantIcon.image="http://websites.goesenroos.nl/general/images/aboverzicht/smartgmap/"+this.iconType+"/kantoor.png";this.kantIcon.shadow="http://websites.goesenroos.nl/general/images/aboverzicht/smartgmap/"+this.iconType+"/shadow-kantoor.png";this.kantIcon.iconSize=new GSize(22,30);this.kantIcon.shadowSize=new GSize(38,30);this.kantIcon.iconAnchor=new GPoint(11,15);this.kantIcon.infoWindowAnchor=new GPoint(11,15);this.myIcon=new GIcon(G_DEFAULT_ICON);this.myIcon.image="http://websites.goesenroos.nl/general/images/aboverzicht/smartgmap/"+this.iconType+"/my.png";this.myIcon.shadow="http://websites.goesenroos.nl/general/images/aboverzicht/smartgmap/"+this.iconType+"/shadow-woning.png";this.myIcon.iconSize=new GSize(22,30);this.myIcon.shadowSize=new GSize(38,30);this.myIcon.iconAnchor=new GPoint(11,15);this.myIcon.infoWindowAnchor=new GPoint(11,15);this.geocoder=new GClientGeocoder()}else{alert("Er is een fout opgetreden bij het laden van google maps.");this.map=null;return null}if(typeof a.useXML!="undefined"){if(!a.useXML){return}if(gr_objExists(document.getElementById("ssInfoHuisID"))){this.myMark=document.getElementById("ssInfoHuisID").value}if(typeof a.xmlPath!="undefined"){this.xmlPath=a.xmlPath}this.parseXML(this.xmlPath)}if(!gr_objExists(document.getElementById("mgmMarkerIDs"))){return}this.parseHTML("AllObjects.xml",this.map,this.geocoder);return this};GR_Maps.prototype.getValid=function(a){if(a.length<=0){return null}if(a[0].childNodes.length<=0){return null}return(typeof a[0].childNodes[0].nodeValue!="string")?null:a[0].childNodes[0].nodeValue};GR_Maps.prototype.parseXML=function(h){if(window.XMLHttpRequest){var g=new XMLHttpRequest()}else{var g=new ActiveXObject("Microsoft.XMLHTTP")}g.open("GET",h,false);g.send("");var e=g.responseXML;var d,c=e.getElementsByTagName("object");if(c.length<=0){return}for(var f=0,a=c.length;f<a;++f){d=c[f];this.baseInfo.id=d.getAttribute("id");if(this.getValid(d.getElementsByTagName("has-gmaps"))!="1"){continue}posCoord=this.getValid(d.getElementsByTagName("coord"));if(posCoord!=null){if(posCoord.indexOf(",")==-1){continue}posCoord=posCoord.split(",")}else{posCoord=[0,0]}if("RecID"+this.baseInfo.id==this.myMark){this.baseInfo.icon=this.myIcon}else{if(this.getValid(d.getElementsByTagName("gebouw-type"))=="BP"){this.baseInfo.icon=this.kantIcon}else{this.baseInfo.icon=this.baseIcon}}this.baseInfo.link=this.getValid(d.getElementsByTagName("deeplink"));this.baseInfo.mainpic=this.getValid(d.getElementsByTagName("hoofdfoto"));this.baseInfo.street=this.getValid(d.getElementsByTagName("straatnaam"));this.baseInfo.num=this.getValid(d.getElementsByTagName("huisnummer"));this.baseInfo.place=this.getValid(d.getElementsByTagName("plaatsnaam"));this.baseInfo.price=this.getValid(d.getElementsByTagName("prijs-html"));this.baseInfo.adres=this.baseInfo.street+" "+this.baseInfo.num+", "+this.baseInfo.place;this.baseInfo.postcode=this.getValid(d.getElementsByTagName("postcode"));if(this.baseInfo.num==0){continue}var b='<div class="MapObject"><img src="'+this.baseInfo.mainpic+'" align="left" class="MapFoto"><span class="MapAdres">'+this.baseInfo.place+"<br>";b+=this.baseInfo.street+" "+this.baseInfo.num+'</span><span class="MapPrijs">'+this.baseInfo.price+'</span><a href="'+this.baseInfo.link+'">Bekijk dit object</a></div>';this.showItem(this.map,this.baseInfo.adres,b,"","RecID"+this.baseInfo.id,posCoord[1],posCoord[0],this.baseInfo.icon,this.baseInfo.postcode,this.baseInfo.num,this)}this.apply()};GR_Maps.prototype.parseHTML=function(g,d,c){if(window.XMLHttpRequest){var f=new XMLHttpRequest()}else{var f=new ActiveXObject("Microsoft.XMLHTTP")}f.open("GET",g,false);f.send("");if(f.readyState==4){if(f.status==200){xmlInfo=f.responseXML;nodes=xmlInfo.getElementsByTagName("object");if(nodes.length<=0){return}for(var e=0,a=nodes.length;e<a;++e){node=nodes[e];this.baseInfo.id=node.getAttribute("id");if(this.getValid(node.getElementsByTagName("has-gmaps"))!="1"){continue}posCoord=this.getValid(node.getElementsByTagName("coord"));if(posCoord!=null){if(posCoord.indexOf(",")==-1){continue}posCoord=posCoord.split(",")}else{posCoord=[0,0]}if(this.getValid(node.getElementsByTagName("gebouw-type"))=="BP"){this.baseInfo.icon=this.kantIcon}else{this.baseInfo.icon=this.baseIcon}this.baseInfo.link=this.getValid(node.getElementsByTagName("deeplink"));this.baseInfo.mainpic=this.getValid(node.getElementsByTagName("hoofdfoto"));this.baseInfo.street=this.getValid(node.getElementsByTagName("straatnaam"));this.baseInfo.num=this.getValid(node.getElementsByTagName("huisnummer"));this.baseInfo.place=this.getValid(node.getElementsByTagName("plaatsnaam"));this.baseInfo.price=this.getValid(node.getElementsByTagName("prijs-html"));this.baseInfo.adres=this.baseInfo.street+" "+this.baseInfo.num+", "+this.baseInfo.place;this.baseInfo.postcode=this.getValid(node.getElementsByTagName("postcode"));if(this.baseInfo.num==0){continue}var b='<div class="MapObject"><img src="'+this.baseInfo.mainpic+'" align="left" class="MapFoto"><span class="MapAdres">'+this.baseInfo.place+"<br>"+this.baseInfo.street+" ";b+=this.baseInfo.num+'</span><span class="MapPrijs">'+this.baseInfo.price+'</span><a href="'+this.baseInfo.link+'">Bekijk dit object</a></div>';outer='<img src="'+this.baseInfo.mainpic+'" class="ObjectFoto"><span class="ObjectAdres">'+this.baseInfo.street+" "+this.baseInfo.num+"<br>"+this.baseInfo.place+"</span>";outer+='<span class="ObjectPrijs">'+this.baseInfo.price+'</span><span class="ObjectLink"><a href="'+this.baseInfo.link+'">Bekijk dit object</a></span>';this.showItem(this.map,this.baseInfo.adres,b,outer,"RecID"+this.baseInfo.id,posCoord[1],posCoord[0],this.baseInfo.icon,this.baseInfo.postcode,this.baseInfo.num,this)}}}};GR_Maps.prototype.genMarker=function(c,a){var b=new GIcon(a);return new GMarker(c,{icon:b})};GR_Maps.prototype.save_coord=function(a){if(window.XMLHttpRequest){var b=new XMLHttpRequest()}else{var b=new ActiveXObject("Microsoft.XMLHTTP")}b.open("GET","../coords.asp?info="+a,false);b.send("")};GR_Maps.prototype.showItem=function(a,c,l,k,j,g,i,h,e,b,f){if(!h){h=this.baseIcon}if(g==0||i==0){f.geocoder.getLatLng(c,function(m){if(m){coord_info="1~"+m.y+","+m.x+"~"+e+b;f.save_coord(coord_info)}})}else{var d=this.genMarker(new GLatLng(i,g),h);GEvent.addListener(d,"click",function(){d.openInfoWindowHtml(l);if(gr_objExists(document.getElementById("mgm"+d.obj))){document.getElementById("mgm"+d.obj).className="ObjectOn";window.location.hash="#mgm"+d.obj}});GEvent.addListener(d,"infowindowclose",function(){if(gr_objExists(document.getElementById("mgm"+d.obj))){document.getElementById("mgm"+d.obj).className="Object"}});GEvent.addListener(d,"infowindowopen",function(){if(typeof window.grStreetClient!="undefined"){window.grStreetClient.getNearestPanorama(d.getLatLng(),setStreetView)}});d.onMap=false;d.obj=j;d.iD=this.markCount++;d.innerMap=l;d.outerMap=k;this.markers.push(d)}};GR_Maps._Call=function(b,a){return function(){b(a)}};GR_Maps.prototype.apply=function(){var k=new GLatLngBounds();var i=false;var a=false;var b=null;if(a){var e=0;var j=[];var h=1;var g=0}for(var c=0;c<this.markers.length;++c){marker=this.markers[c];marker.onMap=true;this.map.addOverlay(marker);if(marker.obj==this.myMark&&!i){i=marker.getLatLng();marker.openInfoWindowHtml(marker.innerMap);b=marker}k.extend(marker.getLatLng())}if(a){for(var c=0;c<this.markers.length;++c){if(e>5){break}marker=this.markers[c];dist=GrGeo.getDistance(b.getLatLng(),marker.getLatLng());if(c==this.markers.length-1&&j.length-1!=5){c=0;g=h+1;h+=2}if(dist>=g&&dist<=h){j.push(marker.obj);e++}}for(var f=0;f<this.markers.length;++f){marker=this.markers[f];if(j.indexOf(marker.obj)==-1){this.markers[f].onMap=true;this.map.removeOverlay(this.markers[f])}}}if(i){this.map.setCenter(i,14)}else{this.map.setCenter(k.getCenter());this.map.setZoom(this.map.getBoundsZoomLevel(k))}this.curZoom=this.map.getZoom()};GR_Maps.prototype.filter=function(b){var c=new GLatLngBounds();if(this.map==null){return}document.getElementById("divObjects").innerHTML="";this.map.closeInfoWindow();for(var a=0;a<this.markers.length;++a){marker=this.markers[a];marker.onMap=false;this.map.removeOverlay(marker)}for(var a=0;a<this.markers.length;++a){marker=this.markers[a];if(b.indexOf(marker.obj)!=-1){marker.onMap=true;this.map.addOverlay(marker);this.genHtml(marker);c.extend(marker.getLatLng())}}this.map.setCenter(c.getCenter());this.map.setZoom(this.map.getBoundsZoomLevel(c));this.curZoom=this.map.getBoundsZoomLevel(c);if(this.markers.length>0){if(gr_objExists(document.getElementById("mgm"+this.markers[0].obj))){document.getElementById("mgm"+this.markers[0].obj).className="ObjectOn";this.markers[0].openInfoWindowHtml(this.markers[0].innerMap)}}};GR_Maps.prototype.genHtml=function(a){var c=document.getElementById("divObjects");var b='<div id="mgm'+a.obj+'" onclick="viewGMap( this,\''+a.iD.toString()+'\')" class="object">';b+=a.outerMap+'</div>\n<div class="ObjectSpacer"></div>';c.innerHTML+=b};setControlButton=function(b){control_elems=document.getElementById("divGoogleMap").getElementsByTagName("div");for(var d=0,a=control_elems.length;d<a;++d){control=control_elems[d];if(control.className.indexOf(b)!=-1){if(control.className.indexOf("active")!=-1){control.className=control.className.substring(0,control.className.length-7)}else{control.className+=" active"}}else{if(control.className.indexOf("active")!=-1){control.className=control.className.substring(0,control.className.length-7)}}}};setStreetView=function(a){if(a.code!=200){return}window.grStreetView.setLocationAndPOV(a.location.latlng,null)};showStreetView=function(){if(!gr_objExists(document.getElementById("streetview"))){return}document.getElementById("streetview").style.display=(document.getElementById("streetview").style.display=="none")?"block":"none"};GR_Maps.prototype.streetview_init=function(){window.grStreetClient=new GStreetviewClient();window.grStreetView=new GStreetviewPanorama(document.getElementById("streetview"));document.getElementById("streetview").style.display="block";setControlButton("grStreetButton")};function StreetViewControl(){}StreetViewControl.prototype=new GControl();StreetViewControl.prototype.initialize=function(f){var d=document.createElement("div");d.className="grControlsContainer";var a=document.createElement("div");a.appendChild(document.createTextNode("Streetview"));GEvent.addDomListener(a,"click",function(){showStreetView();setControlButton(this.className)});this._setDefaultControlStyle(a,"Street");a.rel="[Streetview]Klik hier om streetview in- of uit te schakelen.";d.appendChild(a);var e=document.createElement("div");e.appendChild(document.createTextNode("Kaart"));GEvent.addDomListener(e,"click",function(){f.setMapType(G_NORMAL_MAP)});this._setDefaultControlStyle(e,"Map");e.rel="[Kaart]Kaart weergeven.";e.setAttribute("rel","[Kaart]Kaart weergeven.");d.appendChild(e);var b=document.createElement("div");b.appendChild(document.createTextNode("Sateliet"));GEvent.addDomListener(b,"click",function(){f.setMapType(G_SATELLITE_MAP)});this._setDefaultControlStyle(b,"Satelite");b.rel="[Sateliet]Sateliet beelden weergeven.";d.appendChild(b);var c=document.createElement("div");c.appendChild(document.createTextNode("Beide"));GEvent.addDomListener(c,"click",function(){f.setMapType(G_HYBRID_MAP)});this._setDefaultControlStyle(c,"MapSat");c.rel="[Beide]Beelden met straatnamen weergeven.";d.appendChild(c);f.getContainer().appendChild(d);return d};StreetViewControl.prototype._setDefaultControlStyle=function(b,a){b.className="grControlsButton";a="gr"+a+"Button";if(!b.className.match(new RegExp("\\b"+a+"\\b","i"))){b.className+=(b.className?" ":"")+a}};StreetViewControl.prototype.getDefaultPosition=function(){return new GControlPosition(G_ANCHOR_TOP_RIGHT,new GSize(7,7))};var GrGeo={};GrGeo.earth_radius=6371;GrGeo.getDistance=function(h,g){var d=h.lat()*Math.PI/180;var c=g.lat()*Math.PI/180;var b=d-c;var f=(h.lng()*Math.PI/180)-(g.lng()*Math.PI/180);var a=Math.pow(Math.sin(b/2),2)+Math.cos(c)*Math.cos(d)*Math.pow(Math.sin(f/2),2);var e=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));return Math.round(GrGeo.earth_radius*e)};
