var LLat; var LLong; var localSearch; var myOptions; //////////////// //var localSearch; var myOptions; var pcode; var localSearch; function checkgeo(theform){ if(theform.geo.value != ''){ theform.submit(); }else{ alert('Postcode not found'); } } function get_pcode() { //if( (document.getElementById("postcode").value != 'Enter Postcode') && (document.getElementById("postcode").value != '')) { pcode=document.getElementById("postcode").value; /* if(document.getElementById("postcode").value == ''){ pcode=document.getElementById("postcodep").value; } */ pcode = pcode.replace(' ',''); if((pcode.toUpperCase().match(/GIR 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW])[0-9][ABD-HJLNP-UW-Z]{2}/))){ localSearch = new GlocalSearch(); showPointLatLng = ''; usePointFromPostcode1(pcode,showPointLatLng); } } function get_pcodeqs() { pcode=document.getElementById("postcodeqs").value; pcode = pcode.replace(' ',''); if((pcode.toUpperCase().match(/GIR 0AA|[A-PR-UWYZ]([0-9]{1,2}|([A-HK-Y][0-9]|[A-HK-Y][0-9]([0-9]|[ABEHMNPRV-Y]))|[0-9][A-HJKS-UW])[0-9][ABD-HJLNP-UW-Z]{2}/))){ localSearch = new GlocalSearch(); showPointLatLng = ''; usePointFromPostcodeQs (pcode,showPointLatLng); return true; }else { if( document.getElementById('geoqs')){ document.getElementById('somany').innerHTML = ""; } return false; //alert("Postcode not found!"); } } function usePointFromPostcode1(postcode, callbackFunction) { localSearch = new GlocalSearch(); localSearch.setSearchCompleteCallback(null, function() { if (localSearch.results[0]) { var resultLat = localSearch.results[0].lat; var resultLng = localSearch.results[0].lng; //alert(resultLat+','+resultLng); document.getElementById("geo").value = resultLat+","+resultLng; // var point = new GLatLng(resultLat,resultLng); // callbackFunction(point); return true; }else{ document.getElementById("geo").value = ''; return false; alert("Postcode not found!"); } }); localSearch.execute(postcode + ", UK"); } ////////// function usePointFromPostcodeQs(postcode, callbackFunction) { localSearch = new GlocalSearch(); localSearch.setSearchCompleteCallback(null, function() { if (localSearch.results[0]) { var resultLat = localSearch.results[0].lat; var resultLng = localSearch.results[0].lng; //alert(resultLat+','+resultLng); document.getElementById("geoqs").value=resultLat+","+resultLng; if(document.getElementById('geoqs')){ document.getElementById("geoqs").value=resultLat+","+resultLng; getNumofFA(resultLat,resultLng); } // var point = new GLatLng(resultLat,resultLng); // callbackFunction(point); }else{ // alert("Postcode not found!"); } }); localSearch.execute(postcode + ", UK"); } //////////////////////////////// function initialize(){ if(document.getElementById("map_canvas")){ map = new GMap2(document.getElementById("map_canvas")); map.addControl(new GLargeMapControl()); map.addControl(new GMapTypeControl()); var center = new GLatLng(); map.setCenter(center, 18, G_HYBRID_MAP); // setMarkers(map, branches); /// set up markers var locations = [['',, 0]]; localSearch = new GlocalSearch(); var marker = new GMarker(center, {draggable: true}); GEvent.addListener(marker, "dragstart", function() { map.closeInfoWindow(); }); GEvent.addListener(marker, "dragend", function() { marker.openInfoWindowHtml(" is located here."); var geolocal = String(marker.getLatLng()); geolocal = geolocal.replace('(',''); geolocal = geolocal.replace(')',''); geolocal = geolocal.replace(' ',''); document.getElementById('geo').value = geolocal; if(document.getElementById("geop")){ document.getElementById('geop').value = geolocal; } }); map.addOverlay(marker); } } //placeMarkerAtPoint //setCenterToPoint //showPointLatLng function usePointFromPostcode(postcode, callbackFunction){ localSearch.setSearchCompleteCallback(null, function() { if (localSearch.results[0]) { var resultLat = localSearch.results[0].lat; //alert (resultLat); var LLat=resultLat; var resultLng = localSearch.results[0].lng; var LLong=resultLng; var point = new GLatLng(resultLat,resultLng); callbackFunction(point); }else{ alert("Postcode not found!"); } }); localSearch.execute(postcode + ", UK"); } function placeMarkerAtPoint(point){ var marker = new GMarker(point.lat,point.lng); map.addOverlay(marker); } function setCenterToPoint(point){ map.setCenter(point, 17); } function showPointLatLng(point){ alert("Latitude: " + point.lat() + "\nLongitude: " + point.lng()); } function setMarkers(map, locations) { for (var i = 0; i < locations.length; i++) { var branch = locations[i]; var b1 = locations[i][1]; var b2 = locations[i][2]; var point = new GLatLng(b1,b2); var Icon = new GIcon(); Icon.image = "http://www.google.com/intl/en_us/mapfiles/ms/micons/blue-dot.png"; Icon.iconSize = new GSize(32,32); Icon.iconAnchor = new GPoint(15,28); Icon.infoWindowAnchor = new GPoint(31,8); // Set up our GMarkerOptions object literal markerOptions = { icon:Icon,title: branch[0],draggable: true }; map.addOverlay(new GMarker(point, markerOptions)); /* // g maps 3 code var myLatLng = new google.maps.LatLng(branch[1], branch[2]); var branch = locations[i]; var myLatLng = new google.maps.LatLng(branch[1], branch[2]); var marker = new google.maps.Marker({ position: myLatLng, map: map, title: branch[0], zIndex: branch[3] }); */ } } //////////// function addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); } } } addLoadEvent(initialize); /////////////////////////// function getNumofFA(lat,lng){ var xmlHttpfaq; try// Firefox, Opera 8.0+, Safari {xmlHttpfaq=new XMLHttpRequest(); } catch (e) // Internet Explorer { try {xmlHttpfaq=new ActiveXObject("Msxml2.XMLHTTP");} catch (e) { try { xmlHttpfaq=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {// alert("Your browser does not support AJAX!"); // return false; } } } xmlHttpfaq.onreadystatechange=function(){ if(xmlHttpfaq.readyState==4) {document.getElementById('somany').innerHTML = xmlHttpfaq.responseText;} } xmlHttpfaq.open("GET","/js/yourarea.php?lat="+lat+"&lng="+lng ,true); xmlHttpfaq.send(null); }