var centerLatitude = 51.6245687124; var centerLongitude = -0.779569393298; var startZoom = 10; var map; function init() { map = new GMap2(document.getElementById("map")); //Set minimum and maximum zoom levels G_PHYSICAL_MAP.getMinimumResolution = function () { return 4 }; G_NORMAL_MAP.getMinimumResolution = function () { return 4 }; G_SATELLITE_MAP.getMinimumResolution = function () { return 4 }; G_HYBRID_MAP.getMinimumResolution = function () { return 4 }; G_PHYSICAL_MAP.getMaximumResolution = function () { return 14 }; G_NORMAL_MAP.getMaximumResolution = function () { return 14 }; G_SATELLITE_MAP.getMaximumResolution = function () { return 14 }; G_HYBRID_MAP.getMaximumResolution = function () { return 14 }; //add controls map.addControl( new GLargeMapControl()); map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom); // Create a base icon for all of our markers that specifies the // shadow, icon dimensions, etc. var baseIcon = new GIcon(); baseIcon.shadow = "http://www.google.com/mapfiles/shadow50.png"; baseIcon.iconSize = new GSize(20, 34); baseIcon.shadowSize = new GSize(37, 34); baseIcon.iconAnchor = new GPoint(9, 34); baseIcon.infoWindowAnchor = new GPoint(9, 2); baseIcon.infoShadowAnchor = new GPoint(18, 25); function addMarker(point, markernumber, job_id, job_title, salary, close_date, contract_desc) { // Create a lettered icon for this point using our icon class var letter = String.fromCharCode("A".charCodeAt(0) + markernumber); var letteredIcon = new GIcon(baseIcon); letteredIcon.image = "http://www.google.com/mapfiles/marker" + letter + ".png"; // Set up our GMarkerOptions object markerOptions = { icon:letteredIcon }; var marker = new GMarker(point, markerOptions); //GEvent.addListener(marker, "click", function() { // location.href='#' //}); return marker; } var mapBounds = map.getBounds(); var southWest = mapBounds.getSouthWest(); var northEast = mapBounds.getNorthEast(); var newBounds = new GLatLngBounds(southWest, northEast); for (id in markers) {//itterating through markers //create new GLatLang var point = new GLatLng(markers[id].latitude, markers[id].longitude); var marker = addMarker(point, markers[id].markernumber, markers[id].job_id, markers[id].job_title, markers[id].salary, markers[id].close_date, markers[id].contract_desc) map.addOverlay(marker); //Extend newBounds so that this point is inside newBounds.extend(point); } // Find zoom level that will show all of the points var level = map.getBoundsZoomLevel(newBounds); if (level-1 <= startZoom) { map.setZoom(level-1); } map.setCenter(newBounds.getCenter()); } function loadurlMaps(dest) { try { // Moz supports XMLHttpRequest. IE uses ActiveX. // browser detction is bad. object detection works for any browser jsonhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { // browser doesn't support ajax. handle however you want } // the xmlhttp object triggers an event everytime the status changes // triggered() function handles the events jsonhttp.onreadystatechange = triggeredMaps; // open takes in the HTTP method and url. jsonhttp.open("GET", dest); // send the request. if this is a POST request we would have // sent post variables: send("name=aleem&gender=male) // Moz is fine with just send(); but // IE expects a value here, hence we do send(null); jsonhttp.send(null); } function triggeredMaps() { // if the readyState code is 4 (Completed) // and http status is 200 (OK) we go ahead and get the responseText // other readyState codes: // 0=Uninitialised 1=Loading 2=Loaded 3=Interactive if ((jsonhttp.readyState == 4) && (jsonhttp.status == 200)) { // jsonhttp.responseText object contains the response. //var markers = eval('(' + jsonhttp.responseText + ')'); //first delete all old references scripts with id=mapData var mapData = document.getElementById("mapData"); var head = document.getElementsByTagName("head")[0]; if (mapData) { head.removeChild(mapData); } //alert(jsonhttp.responseText); //create new script newScript=document.createElement('script'); document.getElementsByTagName('head')[0].appendChild(newScript); newScript.id = "mapData"; newScript.type = "text/javascript"; newScript.language = "javascript"; newScript.text = jsonhttp.responseText; //alert(markers.length); init(); } }