PHP - Moved: Gmap Help With Ajax
This topic has been moved to Ajax Help.
http://www.phpfreaks.com/forums/index.php?topic=309753.0 Similar Tutorialshello im having some trouble with my gmap its just that all my markers are showing all the data from the last child of the xml file ill explain my code here for beta explanation first after the form as been submitted, it gets all the posted data from the form, then searches the database and returns all it matches and returns it back to the user, then it writes it all to an xml and then calls the displaymap.php $dom = new DOMDocument("1.0"); $node = $dom->createElement("markers"); $parnode = $dom->appendChild($node); //query for doctor name //query to search for all doctors that match the selected value of the langspoken dropdown box $gmapSql = "SELECT * FROM Doctor"; $gmapResult = $mdb2->query($gmapSql); $rowsFound = ($gmapResult->numRows()); if(PEAR::isError($mdb2)) { echo $mdb2->getMessage() . "<br/>\n"; echo $mdb2->getUserinfo() . "<br/>\n"; exit; } //checks if any exists and displays it or displays none has been found if(($gmapResult->numRows()) != 0) { // Report how many rows were found $rowsfoundmessage = "{$rowsFound} records of doctors found matching your criteria <br> Address Entered: {$address} <br> Radius(km): {$KMradius}"; $template->setCurrentBlock("resultsfound"); $template->setVariable("RESULTSFOUND",$rowsfoundmessage); $template->parseCurrentBlock("resultsfond"); } else { $rowsfoundmessage = 'No records of doctors match your search criteria'; $template->setCurrentBlock("resultsfound"); $template->setVariable("RESULTSFOUND",$rowsfoundmessage); $template->parseCurrentBlock("resultsfound"); } if ($rowsFound > 0) { // Fetch each of the query rows while ($row = $gmapResult->fetchRow()) { //details it back to the user using the PEAr placeholders $template->setCurrentBlock("doctorinfo"); $template->setVariable("DOCTORNAME","{$row['Title']} {$row['GivenName']} {$row['Surname']}"); $template->setVariable("DOCTORLANG", $row['LanguageSpoken']); $template->setVariable("DOCTOROFFICEADD", $row['OfficeAddress']); $template->setVariable("DOCTOROFFICENUM", $row['OfficeNumber']); $template->setVariable("DOCTORSPECIAL", $row['Qualifications']); $template->parseCurrentBlock("doctorinfo"); // ADD TO XML DOCUMENT NODE $node = $dom->createElement("marker"); $newnode = $parnode->appendChild($node); //created attributes for each marker containing doctors details $newnode->setAttribute("DoctorName","{$row['Title']} {$row['GivenName']} {$row['Surname']}"); $newnode->setAttribute("OfficeAddress", $row['OfficeAddress']); $newnode->setAttribute("OfficeNumber", $row['OfficeNumber']); $newnode->setAttribute("LanguageSpoken", $row['LanguageSpoken']); $newnode->setAttribute("Specialty", $row['LanguageSpoken']); } // end while loop body } // end if $rowsFound body //save as an xml and overwrite existing one with this data echo $dom->saveXML(); $dom->save("markers.xml"); //call this script to display the google map echo "<script type=\"text/javascript\" src=\"displaymap.php?address=".$address."&KMradius=".$KMradius."\"></script>"; opens the displaymap.php and starts the map, makes a marker of ur location and draws a radius it then opens the xml file, searches each child and makes a marker for it and put it on the map my PROBLEM is the infowindow for each marker on the map only shows details for the last child on the xml, at ffirst i was pretty sure it would work fine since its all in for loop so that each marker it makes it shows coresponding details. Could it be that everytime it goes in the for loop it overrides the marker2 variable with the new details? is there a solution to this?? //Get the data from the url and store it in a javascript variable var address = "<?php echo $_GET['address'];?>"; var KMradius = "<?php echo $_GET['KMradius'];?>"; //call the functions with those parameters showAddress(address,KMradius);return false; function showAddress(address,KMradius) { //converts KM radius into Miles MIRadius = KMradius * 0.62137119; if (geocoder) { geocoder.getLatLng(address,function(point) { //checks the address entered is a valid geocode address if (!point) { alert("Address: "+address + " not found"); } else { //if it is set the center of the map of that address map.setCenter(point, 10); var marker = new GMarker(point, {draggable: true}); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml("<p>Address: <b>" + address + "</b><p>Your Are here! </p>"); }); //sets the latitude and longtude of the address into variables var lati=point.lat(); var long=point.lng(); //add the marker of the address onto the map map.addOverlay(marker); marker.openInfoWindowHtml("<p>Address: <b>" + address + "</b><p>Your Are here! </p>"); //calls the functions with the latitude,longtude and radius and also the thickness and color of the circle drawCircle(lati,long,MIRadius, "#000080",1, .5, "#0000FF", .5); } } ); } //opens the xml with all the markers and parses the data GDownloadUrl("markers.xml", function(data) { var xml = GXml.parse(data); //goes into the root element of the xml var markers = xml.documentElement.getElementsByTagName("marker"); //for each marker element in the xml, create a new marker from the address attribute for (var i = 0; i < markers.length; i++) { //gets the values of each attribute for each marker element var GivenName = markers[i].getAttribute("DoctorName"); var OfficeNumber = markers[i].getAttribute("OfficeNumber"); var LanguageSpoken = markers[i].getAttribute("LanguageSpoken"); var addresss = markers[i].getAttribute("OfficeAddress"); var special = markers[i].getAttribute("Specialty"); //alert(GivenName); //alert(OfficeNumber); //alert(LanguageSpoken); //alert(addresss); //alert(special); if (geocoder) { geocoder.getLatLng(addresss,function(point) { if (!point) { //if the address in the xml in not a valid geocode address, alert the user alert("Address: "+addresss+ " not found"); } else { //make a variable each for latitude and longatude for the point var lati2 = point.lat(); var long2 = point.lng(); //make a point containing the latitude and longatude var point = new GLatLng(lati2,long2); //created a marker for that point var marker2 = new GMarker(point,{draggable: false}); GEvent.addListener(marker2, "click", function() { marker2.openInfoWindowHtml("Office Address:" + addresss + "<br/>Language Spoken: "+ LanguageSpoken + "<br/>Doctor Name:" + GivenName+ "<br/>Office Number: "+ OfficeNumber+ "."); }); //var marker2 = createMarker(point,); //add the marker of the address in the xml onto the map map.addOverlay(marker2); } } ); } } }); } thanks Just want to ask, is it possible to display gmap dynamically based on user IP address which has been stored inside database how can i do that? thanks This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=325858.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=312841.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=351379.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=333348.0 I had bought a script from he php google maps and have been using the attached php script. It was working and than apparently stopped working with this error "602: Unable to Geocode this address" Can anyone tell me if there is another solution? Or if I can use another method besides $gmap->showLocation($cross,$town,$county$state); Thanks! Code: [Select] <?php require_once('gmap.php'); $gmap = new GMap(); $cross = $result['cross_streets']; $county = $result['county']; $town = $result['town']; $state = 'New York'; $gmap->showLocation($cross,$town,$county$state); ?> This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=323434.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=332473.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=319274.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=308756.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=314220.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=320161.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=314117.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=350592.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=347835.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=348693.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=347705.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=334644.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=343073.0 |