you can download my files at http://www.rith.ca/LABS/maps/ do you think you can make changes and email the files back to me?
On Aug 26, 11:51 pm, Grok Lobster <[email protected]> wrote: > Is there a new link? The one above shows no change. > > On Aug 26, 8:17 pm, Charith <[email protected]> wrote: > > > > > > > > > I tried that. It still didnt work. Still get the same error > > > On Aug 26, 5:37 pm, Grok Lobster <[email protected]> wrote: > > > > This file -http://www.rith.ca/LABS/maps/phpsqlajax_genxml.php-that > > > you call in downloadUrl > > > > returns data of the form > > > > connected to db > > > db selected > > > 1 | Pan Africa Market | 1521 1st Ave, Seattle, WA | 47.608940 | > > > -122.340141 | restaurant > > > 2 | Buddha Thai & Bar | 2222 2nd Ave, Seattle, WA | 47.613590 | > > > -122.344391 | bar > > > 3 | The Melting Pot | 14 Mercer St, Seattle, WA | 47.624561 | > > > -122.356445 | restaurant > > > 4 | Ipanema Grill | 1225 1st Ave, Seattle, WA | 47.606365 | > > > -122.337654 | restaurant > > > 5 | Sake House | 2230 1st Ave, Seattle, WA | 47.612823 | -122.345673 | > > > bar > > > 6 | Crab Pot | 1301 Alaskan Way, Seattle, WA | 47.605961 | -122.340363 > > > | restaurant > > > 7 | Mama's Mexican Kitchen | 2234 2nd Ave, Seattle, WA | 47.613976 | > > > -122.345467 | bar > > > 8 | Wingdome | 1416 E Olive Way, Seattle, WA | 47.617214 | -122.326584 > > > | bar > > > 9 | Piroshky Piroshky | 1908 Pike pl, Seattle, WA | 47.610126 | > > > -122.342834 | restaurant > > > > which won't work with the rest of the script. > > > Change the above referenced file to the xml file that you created > > > manually. > > > > On Aug 26, 12:42 pm, Charith <[email protected]> wrote: > > > > > I am trying to get google maps working with markers from an xml file. > > > > I found this website (http://code.google.com/apis/maps/articles/ > > > > phpsqlajax_v3.html) and i followed it to the dot. I got an error > > > > saying that "request" is not defined so moved the request object > > > > declaration to the top instead of where it is in that website posted > > > > above. > > > > Now i get documentElement is null or not an object error. Anyone have > > > > any idea what is going on? everything seems to be good. well, looks > > > > good for me at least. What is it that I am missing and doing wrong? > > > > > Demo:http://www.rith.ca/LABS/maps/map.html > > > > > --------------------------------------------------------------------------- > > > > -------------------------- > > > > map.html code > > > > --------------------------------------------------------------------------- > > > > -------------------------- > > > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > > > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > > > > <html> > > > > <head> > > > > <meta name="viewport" content="initial-scale=1.0, user- > > > > scalable=no" /> > > > > <meta http-equiv="content-type" content="text/html; charset=UTF-8"/ > > > > > <title>PHP/MySQL & Google Maps Example</title> > > > > <script type="text/javascript" src="http://maps.google.com/maps/ > > > > api/js?sensor=false"></script> > > > > <script type="text/javascript"> > > > > //<![CDATA[ > > > > > var request = window.ActiveXObject ? > > > > new ActiveXObject('Microsoft.XMLHTTP') : > > > > new XMLHttpRequest; > > > > > var customIcons = { > > > > restaurant: { > > > > icon: 'http://labs.google.com/ridefinder/images/ > > > > mm_20_blue.png', > > > > shadow: 'http://labs.google.com/ridefinder/images/ > > > > mm_20_shadow.png' > > > > }, > > > > bar: { > > > > icon: 'http://labs.google.com/ridefinder/images/ > > > > mm_20_red.png', > > > > shadow: 'http://labs.google.com/ridefinder/images/ > > > > mm_20_shadow.png' > > > > } > > > > }; > > > > > function load() { > > > > var map = new google.maps.Map(document.getElementById('map'), { > > > > center: new google.maps.LatLng(47.6145, -122.3418), > > > > zoom: 13, > > > > mapTypeId: 'roadmap' > > > > }); > > > > var infoWindow = new google.maps.InfoWindow; > > > > if(null == infoWindow) { alert("Object InfoWindow Null"); } > > > > > // Change this depending on the name of your PHP file > > > > downloadUrl("phpsqlajax_genxml.php", function(data) { > > > > var xml = request.responseXML; > > > > if(null == xml) { alert("Object xml Null"); } > > > > > var markers = > > > > xml.documentElement.getElementsByTagName('marker'); > > > > for (var i = 0; i < markers.length; i++) { > > > > var name = markers[i].getAttribute('name'); > > > > var address = markers[i].getAttribute('address'); > > > > var type = markers[i].getAttribute('type'); > > > > var point = new google.maps.LatLng( > > > > parseFloat(markers[i].getAttribute('lat')), > > > > parseFloat(markers[i].getAttribute('lng'))); > > > > var html = "" + name + " " + address; > > > > var icon = customIcons[type] || {}; > > > > var marker = new google.maps.Marker({ > > > > map: map, > > > > position: point, > > > > icon: icon.icon, > > > > shadow: icon.shadow > > > > }); > > > > bindInfoWindow(marker, map, infoWindow, html); > > > > } > > > > }); > > > > } > > > > > function bindInfoWindow(marker, map, infoWindow, html) { > > > > google.maps.event.addListener(marker, 'click', function() { > > > > infoWindow.setContent(html); > > > > infoWindow.open(map, marker); > > > > }); > > > > } > > > > > function downloadUrl(url, callback) { > > > > request.onreadystatechange = function() { > > > > if (request.readyState == 4) { > > > > request.onreadystatechange = doNothing; > > > > callback(request, request.status); > > > > } > > > > }; > > > > > request.open('GET', url, true); > > > > request.send(null); > > > > } > > > > > function doNothing() {} > > > > > //]]> > > > > > </script> > > > > > </head> > > > > > <body onload="load()"> > > > > <div id="map" style="width: 500px; height: 300px"></div> > > > > </body> > > > > > </html> > > > > > --------------------------------------------------------------------------- > > > > -------------------------- > > > > phpsqlajax_genxml.php code > > > > --------------------------------------------------------------------------- > > > > -------------------------- > > > > <?php > > > > $username="root"; > > > > $password="**********"; // I use the actual password instead of the > > > > stars here > > > > $database="google"; > > > > > // Start XML file, create parent node > > > > > $dom = new DOMDocument('1.0', 'iso-8859-1'); > > > > $node = $dom->createElement("markers"); > > > > $parnode = $dom->appendChild($node); > > > > > // Opens a connection to a MySQL server > > > > > $connection=mysql_connect (localhost, $username, $password); > > > > if (!$connection) { die('Not connected : ' . mysql_error());} else > > > > { echo "connected to db<br />"; } > > > > > // Set the active MySQL database > > > > > $db_selected = mysql_select_db($database, $connection); > > > > if (!$db_selected) { > > > > die ('Can\'t use db : ' . mysql_error());} > > > > > else { echo "db selected<br />"; } > > > > > // Select all the rows in the markers table > > > > > $query = "SELECT * FROM markers"; > > > > $result = mysql_query($query); > > > > if (!$result) { > > > > die('Invalid query: ' . mysql_error()); > > > > > } > > > > > //header("Content-type: text/xml"); > > > > > // Iterate through the rows, adding XML nodes for each > > > > > while ($row = @mysql_fetch_assoc($result)){ > > > > echo $row[id] . " | " . $row[name] . " | " . $row[address] . " > > > > | " . > > > > $row[lat] . " | " . $row[lng] . " | " . $row[type] . "<br />"; > > > > // ADD TO XML DOCUMENT NODE > > > > $node = $dom->createElement("marker"); > > > > $newnode = $parnode->appendChild($node); > > > > $newnode->setAttribute("name",$row['name']); > > > > $newnode->setAttribute("address", $row['address']); > > > > $newnode->setAttribute("lat", $row['lat']); > > > > $newnode->setAttribute("lng", $row['lng']); > > > > $newnode->setAttribute("type", $row['type']); > > > > > } > > > > > echo $dom->saveXML(); > > > > > ?> > > > > > --------------------------------------------------------------------------- > > > > -------------------------- > > > > phpsqlajax_expectedoutput.xml code > > > > Above script didnt create the xml file. I manually put in the data > > > > into this xml file > > > > --------------------------------------------------------------------------- > > > > -------------------------- > > > > <?xml version="1.0" encoding="iso-8859-1"?> > > > > <markers> > > > > <marker name="Pan Africa Market" address="1521 1st Ave, Seattle, WA" > > > > lat="47.608940" lng="-122.340141" type="restaurant"/> > > > > <marker name="Buddha Thai & Bar" address="2222 2nd Ave, Seattle, WA" > > > > lat="47.613590" lng="-122.344391" type="bar"/> > > > > <marker name="The Melting Pot" address="14 Mercer St, Seattle, WA" > > > > lat="47.624561" lng="-122.356445" type="restaurant"/> > > > > <marker name="Ipanema Grill" address="1225 1st Ave, Seattle, WA" > > > > lat="47.606365" lng="-122.337654" type="restaurant"/> > > > > <marker name="Sake House" address="2230 1st Ave, Seattle, WA" > > > > lat="47.612823" lng="-122.345673" type="bar"/> > > > > <marker name="Crab Pot" address="1301 Alaskan Way, Seattle, WA" > > > > lat="47.605961" lng="-122.340363" type="restaurant"/> > > > > <marker name="Mama's Mexican Kitchen" address="2234 2nd Ave, Seattle, > > > > WA" lat="47.613976" lng="-122.345467" type="bar"/> > > > > <marker name="Wingdome" address="1416 E Olive Way, Seattle, WA" > > > > lat="47.617214" lng="-122.326584" type="bar"/> > > > > <marker > > ... > > read more » -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.
