function update_point_info(point_id){ $.ajax({ type: "POST", url: 'http://www.pogo-direct.co.uk/ajax_get_point_info.php', data: "get_point_info=true&point_id="+point_id+"", success: function(msg){ $('#point_info').html(msg); hide_loader(); marker_listener_on=1; } }); } function checkPostCode (toCheck) { // Permitted letters depend upon their position in the postcode. var alpha1 = "[abcdefghijklmnoprstuwyz]"; // Character 1 var alpha2 = "[abcdefghklmnopqrstuvwxy]"; // Character 2 var alpha3 = "[abcdefghjkstuw]"; // Character 3 var alpha4 = "[abehmnprvwxy]"; // Character 4 var alpha5 = "[abdefghjlnpqrstuwxyz]"; // Character 5 // Array holds the regular expressions for the valid postcodes var pcexp = new Array (); // Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA pcexp.push (new RegExp ("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1,2})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i")); // Expression for postcodes: ANA NAA pcexp.push (new RegExp ("^(" + alpha1 + "{1}[0-9]{1}" + alpha3 + "{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i")); // Expression for postcodes: AANA NAA pcexp.push (new RegExp ("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1}" + alpha4 +"{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i")); // Exception for the special postcode GIR 0AA pcexp.push (/^(GIR)(\s*)(0AA)$/i); // Standard BFPO numbers pcexp.push (/^(bfpo)(\s*)([0-9]{1,4})$/i); // c/o BFPO numbers pcexp.push (/^(bfpo)(\s*)(c\/o\s*[0-9]{1,3})$/i); // Load up the string to check var postCode = toCheck; // Assume we're not going to find a valid postcode var valid = false; // Check the string against the types of post codes for ( var i=0; i'); $('#map').append('
Loading...
'); } function hide_loader(){ $('#loader_notifier_info').remove(); $('#loader_notifier_info_all').remove(); } if (GBrowserIsCompatible()) { var map; var geo; var reasons=[]; var gmarkers = []; var gmarkers_1 = []; var gmarkers_2 = []; var htmls = []; var no_of_villa = 0; var small_map; var map_center_lat; var map_center_lng; var bounds = new GLatLngBounds(); var maxdistance = 50; var pid = ''; var marker_listener_on = 1; var after_move = 0; function setupDragZoom() { /* first set of options is for the visual overlay.*/ var boxStyleOpts = { opacity: .2, border: "2px solid red" }; /* second set of options is for everything else */ var otherOpts = { buttonHTML: "", buttonZoomingHTML: "", buttonStartingStyle: {width: '24px', height: '24px'}, overlayRemoveTime: 1000 }; map.addControl(new DragZoomControl(boxStyleOpts, otherOpts, {}), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(23, 270))); } function toggle_logo(elementId) { var source = document.getElementById(elementId); //Terms of use link var divs = source.getElementsByTagName('div'); var current = (divs[14].style.display == 'none') ? 'block' : 'none'; divs[14].style.display = current; //Google Logo link /*var links = source.getElementsByTagName('a'); var current = (links[1].style.display == 'none') ? 'block' : 'none'; links[1].style.display = current;*/ } // This function just makes a pretty table for the EWindow contents // With a close icon function pretty(a,b) { return '' + '
' + a + '
' + b + '
'; } function createIcon(image){ var image_ico = "http://www.pogo-direct.co.uk/upload/points_types/"+image; var icon = new GIcon(); icon.image = image_ico; icon.iconAnchor = new GPoint(6, 20); icon.infoWindowAnchor = new GPoint(5, 1); return icon; } function createMarker_view(point, id, name, description, type, image_icon, image, url, point_url, rel_id) { var icon = createIcon(image_icon); var marker = new GMarker(point, icon); marker.mycategory = type; marker.myname = id; var imageadd = ''; var link = ''; var urllink = ''; if(image!=''){ imageadd = "
"; } if(point_url!=''){ link = point_url; } if(url!=''){ urllink = "View more >>    "; } var html = "
"+ imageadd +"
" + description+"
"; html = pretty(name,html); if(name!="" || description!="" || image!=""){ if(pid==id && pid>0 ){ ew.openOnMarker(marker,html); } GEvent.addListener(marker, 'mouseover', function() { if(marker_listener_on==1){ ew.openOnMarker(marker,html); } }); GEvent.addListener(marker, 'mouseout', function() { if(marker_listener_on==1){ ew.hide(); } }); } GEvent.addListener(marker, 'click', function() { marker_listener_on = 0; ew.openOnMarker(marker,html); pid = id; show_loader(); update_point_info(id); }); gmarkers.push(marker); return marker; } function update_pint_types(){ var arr = $("input"); jQuery.each(arr, function() { if(this.name=='box'){ if (this.checked) { show(this.value); } else { hide(this.value); } } }); } function boxclick_distance(mdistance) { var point = map.getCenter(); maxdistance = mdistance; mdistance = mdistance*1.60934; var distance = 0; for (var i=0; i0){ if(distance<=mdistance){ if(gmarkers_1[i] == true){ gmarkers[i].show(); } gmarkers_2[i] = true; }else{ gmarkers[i].hide(); gmarkers_2[i] = false; } }else{ if(gmarkers_1[i] == true){ gmarkers[i].show(); } gmarkers_2[i] = true; } } } // == shows all markers of a particular category, and ensures the checkbox is checked == function show(category) { for (var i=0; i0){ var distance = point.distanceFrom(marker.getPoint())/1000; if(distance>maxdistance){ gmarkers_2[i] = false; } }*/ } update_pint_types(); $('#no_of_points').html(markers.length+" points displayed on map"); //boxclick_distance(maxdistance); marker_listener_on = 1; if(after_move == 1){ ew.hide(); after_move = 1; } $('#no_of_points').html(msg1+" properties in this area."); hide_loader(); }); }else{ $('#no_of_points').html(msg1+" properties in this area. Please Zoom In to view."); hide_loader(); } } }); } function initialize_main_map(plat, plng, point_id) { map = new GMap2(document.getElementById("map")); geo = new GClientGeocoder(); reasons[G_GEO_SUCCESS] = "Success"; reasons[G_GEO_MISSING_ADDRESS] = "Missing Address: The address was either missing or had no value."; reasons[G_GEO_UNKNOWN_ADDRESS] = "Unknown Address: No corresponding geographic location could be found for the specified address."; reasons[G_GEO_UNAVAILABLE_ADDRESS]= "Unavailable Address: The geocode for the given address cannot be returned due to legal or contractual reasons."; reasons[G_GEO_BAD_KEY] = "Bad Key: The API key is either invalid or does not match the domain for which it was given"; reasons[G_GEO_TOO_MANY_QUERIES] = "Too Many Queries: The daily geocoding quota for this site has been exceeded."; reasons[G_GEO_SERVER_ERROR] = "Server error: The geocoding request could not be successfully processed."; if(plat=='' && plng==''){ plat = 36.990000; plng = -3.886792; } pid = point_id; var center = new GLatLng(plat, plng); map.setCenter(center, 10); var marker; //boxclick_distance(50); toggle_logo('map'); update_markers(); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); //map.addControl(new GOverviewMapControl()); //map.addControl(new GScaleControl()); map.enableDoubleClickZoom(); setupDragZoom(); GEvent.addListener(map,'click',function() { if(marker_listener_on==1){ ew.hide(); } }); GEvent.addListener(map,'zoomend',function() { after_move = 1; update_markers(); }); GEvent.addListener(map,'moveend',function() { after_move = 1; update_markers(); }); } // ====== Plot a marker after positive reponse to "did you mean" ====== function place(lat,lng) { var point = new GLatLng(lat,lng); map.setCenter(point); update_markers(); var marker_point = new GMarker(point, { draggable: true}); map.addOverlay(marker_point); document.getElementById("message").innerHTML = ""; } // ====== Geocoding ====== function showAddress() { var search1 = document.getElementById("search").value; var s; if (!checkPostCode(search1)){ s = search1; } else { s = checkPostCode(search1); } // ====== Perform the Geocoding ====== geo.getLocations(s, function (result) { //map.clearOverlays(); if (result.Status.code == G_GEO_SUCCESS) { // ===== If there was more than one result, "ask did you mean" on them all ===== if (result.Placemark.length > 1) { document.getElementById("message").innerHTML = "Did you mean:"; // Loop through the results for (var i=0; i"+ result.Placemark[i].address+""; } } // ===== If there was a single marker ===== else { document.getElementById("message").innerHTML = ""; var p = result.Placemark[0].Point.coordinates; place(p[1],p[0]); } } // ====== Decode the error status ====== else { var reason="Code "+result.Status.code; if (reasons[result.Status.code]) { reason = reasons[result.Status.code] } alert('Could not find "'+s+ '" ' + reason); } } ); } }else { alert("Sorry, the Google Maps API is not compatible with this browser"); }