function showMap(cLat,cLong){ // A function to create the marker and set up the event window function createMarkercreateMarker(point,iconImage,moverImage,classId,linkId,iconClass,infoTab) { var Icon = new GIcon(G_DEFAULT_ICON); Icon.image =iconImage; Icon.iconAnchor=new GPoint(20,35); Icon.infoWindowAnchor=new GPoint(25,0); Icon.iconSize = new GSize(29, 37); var marker = new GMarker(point,Icon); // Switch icon on marker mouseover and mouseout GEvent.addListener(marker, "mouseover", function() { marker.setImage(moverImage); document.getElementById(linkId).style.background="#EEEEEE"; document.getElementById(classId).className =iconClass+'on'; }); GEvent.addListener(marker, "mouseout", function() { marker.setImage(iconImage); document.getElementById(linkId).style.background="#FFFFFF"; document.getElementById(classId).className =iconClass; }); GEvent.addListener(marker, "click", function() { marker.openInfoWindowTabsHtml(infoTab); }); return marker; } function updateResult(map){ GEvent.addListener(map, "moveend", function() { var center = map.getCenter(); var linkTxt='/search_results.php?cLat='+center.y+'&cLong='+center.x+'&radius=60'; var result_update='
salford gym<\/div><\/a>'; document.getElementById("update").innerHTML =result_update; }); } // create the map var map = new GMap2(document.getElementById("map")); map.addControl(new GSmallMapControl()); map.setCenter(new GLatLng(cLat,cLong),9); // Read the data from example.xml var request = GXmlHttp.create(); request.open("GET", "/marker.php?m=3782912", true); request.onreadystatechange = function() { if (request.readyState == 4) { var xmlDoc = GXml.parse(request.responseText); // obtain the array of markers and loop through it var markers = xmlDoc.documentElement.getElementsByTagName("marker"); var test; for (var i = 0; i < markers.length; i++) { // obtain the attribues of each marker var lat = parseFloat(markers[i].getAttribute("lat")); var lng = parseFloat(markers[i].getAttribute("lng")); var point = new GLatLng(lat,lng); var status = markers[i].getAttribute("status"); var title = markers[i].getAttribute("title"); var address = markers[i].getAttribute("address"); var phone_no = markers[i].getAttribute("phone_no"); var profileLink = markers[i].getAttribute("profileLink"); var siteLink = markers[i].getAttribute("siteLink"); var hide_site = markers[i].getAttribute("hide_site"); var hide_profile = markers[i].getAttribute("hide_profile"); var logo_link = markers[i].getAttribute("logo_link"); var hide_logo = markers[i].getAttribute("hide_logo"); if(status==2 || status==3){ var iconId='promoIcon'+character[i]+'.png'; var moverIconId='promoIcon'+character[i]+'on.png'; var iconClass='icon promoicon'+character[i]; }else{ var iconId='icon'+character[i]+'.png'; var moverIconId='icon'+character[i]+'on.png'; var iconClass='icon icon'+character[i]; } var iconImage='/lib/images/'+iconId; var moverImage='/lib/images/'+moverIconId; var linkId='link'+i; var classId='class'+i; var option_details = "

"; option_details +="" + title + "<\/b>
"; if(hide_logo == 0) option_details +=""; option_details += address + "
" + phone_no + "
"; if(hide_profile == 0) option_details += "
View Profile<\/a>"; if(hide_site == 0) { if(hide_profile == 0) option_details += " | "; option_details += "Visit Site<\/a>"; } option_details += "<\/p>"; var infoTab = [ new GInfoWindowTab("Details", option_details)]; // create the marker var marker = createMarkercreateMarker(point,iconImage,moverImage,classId,linkId,iconClass,infoTab); points[i]=point; gmarkers[i]=marker; infoTabs[i]=infoTab; map.addOverlay(marker); } fitMap( map, points ); document.getElementById("loader").style.display='none'; updateResult(map); } } request.send(null); } function mover(id,classId,iconClass,i,moverImage){ if(gmarkers=='')return; gmarkers[i].setImage(moverImage); document.getElementById(id).style.background="#EEEEEE"; document.getElementById(classId).className =iconClass+'on'; } function mout(id,classId,iconClass,i,iconImage){ if(gmarkers=='')return; gmarkers[i].setImage(iconImage); document.getElementById(id).style.background="#FFFFFF"; document.getElementById(classId).className =iconClass; } function mclick(i){ if(infoTabs=='')return; gmarkers[i].openInfoWindowTabsHtml(infoTabs[i]); } function openWindow(id) { url="minimap.php?id="+id; window.open(url,'Minimap','width=400,height=400,menubar=no,status=no,location=no,toolbar=no,scrollbars=no'); } var box = null; function fitMap( map, points ) { var bounds = new GLatLngBounds(); for (var i=0; i< points.length; i++) { bounds.extend(points[i]); } map.setZoom(map.getBoundsZoomLevel(bounds)-1); map.setCenter(bounds.getCenter()); map.showBounds(bounds, paddings); //map.addOverlay(box); } /** * options object for showBounds() */ var paddings = {top:30, right:10, left:40, bottom:10}; /** * GMap2.showBounds() method * @ author Esa 2008 * @ param bounds_ GLatLngBounds() * @ param opt_options Optional options object {top, right, bottom, left, instant, save} */ GMap2.prototype.showBounds = function(bounds_, opt_options){ var opts = opt_options||{}; opts.top = opt_options.top*1||0; opts.left = opt_options.left*1||0; opts.bottom = opt_options.bottom*1||0; opts.right = opt_options.right*1||0; opts.save = opt_options.save||true; opts.disableSetCenter = opt_options.disableSetCenter||false; var ty = this.getCurrentMapType(); var port = this.getSize(); if(!opts.disableSetCenter){ var virtualPort = new GSize(port.width - opts.left - opts.right, port.height - opts.top - opts.bottom); this.setZoom(ty.getBoundsZoomLevel(bounds_, virtualPort)); var xOffs = (opts.left - opts.right)/2; var yOffs = (opts.top - opts.bottom)/2; var bPxCenter = this.fromLatLngToDivPixel(bounds_.getCenter()); var newCenter = this.fromDivPixelToLatLng(new GPoint(bPxCenter.x-xOffs, bPxCenter.y-yOffs)); this.setCenter(newCenter); if(opts.save)this.savePosition(); } var portBounds = new GLatLngBounds(); portBounds.extend(this.fromContainerPixelToLatLng(new GPoint(opts.left, port.height-opts.bottom))); portBounds.extend(this.fromContainerPixelToLatLng(new GPoint(port.width-opts.right, opts.top))); return portBounds; } //////////////////////////////////////////////////////////////////////////////////// /** * GLatLngBounds.drawBox() method * Returns a GPolyline or GPolygon rectangle representing the bounds * optional parameter is an object with style properties {liColor, liWidth, liOpa, fillColor, fillOpa, polygon} * {polygon:true} switches the return object from GPolyline to GPolygon * @author Esa 2007 */ GLatLngBounds.prototype.drawBox = function(opt_options){ var opts = opt_options||{}; var northEast = this.getNorthEast(); var southWest = this.getSouthWest(); var topLat = northEast.lat(); var rightLng = northEast.lng(); var botLat = southWest.lat(); var leftLng = southWest.lng(); var pnts = []; pnts.push(southWest); pnts.push(new GLatLng(topLat,leftLng)); pnts.push(northEast); pnts.push(new GLatLng(botLat,rightLng)); pnts.push(southWest); var fillColor = opts.fillColor||opts.liColor||"none"; var liWidth = opts.liWidth||2; if(opts.polygon){ var boxPoly = new GPolygon(pnts,opts.liColor,liWidth,opts.liOpa,fillColor,opts.fillOpa); }else{ var boxPoly = new GPolyline(pnts,opts.liColor,liWidth,opts.liOpa); } return boxPoly; } // This Javascript is based on code provided by the // Blackpool Community Church Javascript Team // http://www.commchurch.freeserve.co.uk/ // http://econym.googlepages.com/index.htm $(document).ready(function(){ $("table.classifiedAd").bind("mouseover", function(){ if($(this).attr("id") == "link0") mover($(this).attr("id"),'class0','icon iconA',0,'/lib/images/iconAon.png'); else if($(this).attr("id") == "link1") mover($(this).attr("id"),'class1','icon iconB',1,'/lib/images/iconBon.png'); else if($(this).attr("id") == "link2") mover($(this).attr("id"),'class2','icon iconC',2,'/lib/images/iconCon.png'); else if($(this).attr("id") == "link3") mover($(this).attr("id"),'class3','icon iconD',3,'/lib/images/iconDon.png'); else if($(this).attr("id") == "link4") mover($(this).attr("id"),'class4','icon iconE',4,'/lib/images/iconEon.png'); else if($(this).attr("id") == "link5") mover($(this).attr("id"),'class5','icon iconF',5,'/lib/images/iconFon.png'); else if($(this).attr("id") == "link6") mover($(this).attr("id"),'class6','icon iconG',6,'/lib/images/iconGon.png'); else if($(this).attr("id") == "link7") mover($(this).attr("id"),'class7','icon iconH',7,'/lib/images/iconHon.png'); else if($(this).attr("id") == "link8") mover($(this).attr("id"),'class8','icon iconI',8,'/lib/images/iconIon.png'); else if($(this).attr("id") == "link9") mover($(this).attr("id"),'class9','icon iconJ',9,'/lib/images/iconJon.png'); }); $("table.classifiedAd").bind("mouseout", function(){ if($(this).attr("id") == "link0") mout($(this).attr("id"),'class0','icon iconA',0,'/lib/images/iconA.png'); else if($(this).attr("id") == "link1") mout($(this).attr("id"),'class1','icon iconB',1,'/lib/images/iconB.png'); else if($(this).attr("id") == "link2") mout($(this).attr("id"),'class2','icon iconC',2,'/lib/images/iconC.png'); else if($(this).attr("id") == "link3") mout($(this).attr("id"),'class3','icon iconD',3,'/lib/images/iconD.png'); else if($(this).attr("id") == "link4") mout($(this).attr("id"),'class4','icon iconE',4,'/lib/images/iconE.png'); else if($(this).attr("id") == "link5") mout($(this).attr("id"),'class5','icon iconF',5,'/lib/images/iconF.png'); else if($(this).attr("id") == "link6") mout($(this).attr("id"),'class6','icon iconG',6,'/lib/images/iconG.png'); else if($(this).attr("id") == "link7") mout($(this).attr("id"),'class7','icon iconH',7,'/lib/images/iconH.png'); else if($(this).attr("id") == "link8") mout($(this).attr("id"),'class8','icon iconI',8,'/lib/images/iconI.png'); else if($(this).attr("id") == "link9") mout($(this).attr("id"),'class9','icon iconJ',9,'/lib/images/iconJ.png'); }); }); var points = []; var gmarkers = []; var infoTabs = []; var character=Array("A","B","C","D","E","F","G","H","I","J");