/** * Main map functions */ MAPUTILS = function () { //global map object MAPUTILS.prototype.map; MAPUTILS.prototype.counter = 0; MAPUTILS.prototype.currentLat = 37.782; MAPUTILS.prototype.currentLng = -122.412; MAPUTILS.prototype.currentZoom = 13; //alert (G_SATELLITE_MAP); MAPUTILS.prototype.maptype = 1; MAPUTILS.prototype.mapSizeW = 500; MAPUTILS.prototype.mapSizeH = 500; MAPUTILS.prototype.mapLink; MAPUTILS.prototype.initMap = function() { //check if map object has been loaded or created try{ document.getElementById('map').innerHTML; }catch(e){ if (this.counter > 60) { alert('Can\'t load map! Can\'t find map object!'); } else { setTimeout("maputil.initMap()", 1000); } return false; } //If gmaps main.js didn't load try to call init again after 60 tries we give up if (typeof GMap != "function") { if (this.counter > 60) { document.getElementById('map').innerHTML = 'Can\'t load map! Gmap server timeout! '; } else { setTimeout("maputil.initMap()", 1000); } this.counter++; return false; } //if browser not compatible update map tag with error msg if (!GBrowserIsCompatible()) { document.getElementById('map').innerHTML = 'Can\'t load map because your browser is too old!'; return false; } //init gmaps object this.map = new GMap2(document.getElementById("map")); //set center of the map this.map.setCenter(new GLatLng(this.currentLat, this.currentLng), this.currentZoom); if(this.maptype==1) this.map.setMapType(G_NORMAL_MAP); else if(this.maptype==2) this.map.setMapType(G_SATELLITE_MAP); else if(this.maptype==3) this.map.setMapType(G_HYBRID_MAP); //add controls and mouse functions this.map.enableDoubleClickZoom(); this.map.enableContinuousZoom(); this.map.enableScrollWheelZoom(); //this.map.addControl(new GOverviewMapControl (/*new GSize(200,180)*/)); this.map.addControl(new GLargeMapControl()); //zoom and pan this.map.addControl(new GMapTypeControl()); //Map/Sat/hybrid //add zoomend event GEvent.addListener(maputil.map, "zoomend", function() { marker.clearMarkers(); marker.processMarkeres(); marker.hidePointLabelElement(); maputil.setSiteUrl(); }); GEvent.addListener(maputil.map, "dragend", function() { maputil.setSiteUrl(); }); GEvent.addListener(maputil.map, "maptypechanged", function() { maputil.setSiteUrl(); }); //call markers processMarkeres method which will show the markes on the map marker.processMarkeres(); //if zoom is 0 try marker bounds if(this.currentZoom == 0) maputil.map.setCenter(marker.getMarkerCenter(),marker.getZoomLevel()); var decodeUrl = window.location.hash.substring(1).split('='); if(decodeUrl.length>2){ if(parseInt(decodeUrl[1])) this.currentLat = parseInt(decodeUrl[1]) / 1000000; if(parseInt(decodeUrl[2])) this.currentLng = parseInt(decodeUrl[2]) / 1000000; if(parseInt(decodeUrl[3])) this.currentZoom = parseInt(decodeUrl[3]); if(parseInt(decodeUrl[5])) this.maptype = parseInt(decodeUrl[5]); var checked = decodeUrl[4].split(','); //alert(checked); for(i=0;i<20;i++){ try{ document.getElementById('filtermarkes_'+i).checked = false; if(checked.indexOf(i+'') != -1 || checked.indexOf(i+'|type') != -1) document.getElementById('filtermarkes_'+i).checked = true; }catch(e){} } maputil.map.setCenter(new GLatLng(this.currentLat, this.currentLng), this.currentZoom); if(this.maptype==1) maputil.map.setMapType(G_NORMAL_MAP); else if(this.maptype==2) maputil.map.setMapType(G_SATELLITE_MAP); else if(this.maptype==3) maputil.map.setMapType(G_HYBRID_MAP); } marker.processMarkeres(); //try{ // bind a search control to the map, suppress result list maputil.map.addControl(new google.maps.LocalSearch(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(100,5))); //}catch(e){} this.setSiteUrl(); if((decodeUrl[4])) marker.filter(); } MAPUTILS.prototype.setMapSize = function (){ document.getElementById("map").style.width = this.mapSizeW + 'px'; document.getElementById("map").style.height = this.mapSizeH + 'px'; } MAPUTILS.prototype.setSiteUrl = function(){ var center = maputil.map.getCenter(); var aaa = maputil.map.getCurrentMapType().getName(); var aaa2=1; if(aaa=="Map") aaa2 = 1; else if(aaa=="Satellite") aaa2 = 2; else aaa2 = 3; //alert(aaa2); //get checkbox statetes var checkBoxStates = new Array(); for(i=0;i<20;i++){ try{ if(document.getElementById('filtermarkes_'+i).checked) checkBoxStates.push(i); }catch(e){} } //alert(center); maputil.mapLink = 'lat=' + Math.round(center.y*1000000) + '|lng=' + Math.round(center.x*1000000) + '|zoom=' + maputil.map.getZoom() + '|checked=' + checkBoxStates.toString() + '|type=' + aaa2; window.location = window.location.pathname + '#' + maputil.mapLink; } } /** * Marker class. Handle markers and lables */ MARKERS = function () { //this will store the markers MARKERS.prototype.markersDb = new Array(); //define icons path MARKERS.prototype.markerIconsPath = '/re/img/'; //store bounds MARKERS.prototype.bounds = new GLatLngBounds(); MARKERS.prototype.showPointLabel = function (anchor){ marker.showLabel(anchor.id); anchor.style.zIndex=4; return false; } MARKERS.prototype.hidePointLabel = function (anchor){ anchor.style.zIndex=1; this.hidePointLabelElement(); return false; } MARKERS.prototype.hidePointLabelElement = function (){ try{ document.getElementById("infoLabel").style.display = 'none'; }catch(e){} } MARKERS.prototype.processMarkeres = function(){ var pointsHtml = ''; //go thru markersDb and build up a layer for the map for(i=0;i