Google Maps API in WordPress

Ich erhalte den Fehler “documentElement of null”. Ich versuche zu folgen https://developers.google.com/maps/articles/phpsqlajax_v3 UPDATE: Bei der Verwendung von Dev-Tools scheint es, dass die “DownloadUrl ()” -function Probleme hat.

Mein “phpsqlajax_genxml.php” create_element (“markers”); $ parnode = $ doc-> append_child ($ node);

// Opens a connection to a mySQL server /*$connection=mysql_connect (localhost, $username, $password); if (!$connection) { die('Not connected : ' . mysql_error()); } // Set the active mySQL database $db_selected = mysql_select_db($database, $connection); if (!$db_selected) { die ('Can\'t use db : ' . mysql_error()); }*/ // Select all the rows in the markers table global $wpdb ; //$query = "SELECT * FROM markers WHERE 1"; $query = $wpdb->get_results("SELECT * FROM `markers` WHERE 1;") ; /*no need of this $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 foreach ($query as $q) { // ADD TO XML DOCUMENT NODE echo 'name) . '" '; echo 'address="' . parseToXML($q->address) . '" '; echo 'lat="' . $q->lat . '" '; echo 'lng="' . $q->lng . '" '; echo 'type="' . $q->type . '" '; echo '/>'; } ?> 

Meine “stündliche.php” Datei, die xml von der obigen Datei übernimmt

    //<![CDATA[ var customIcons = { restaurant: { icon: 'http://img.daswordpress.com/google-maps/mm_20_blue.png' }, bar: { icon: 'http://img.daswordpress.com/google-maps/mm_20_red.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; // Change this depending on the name of your PHP file downloadUrl("phpsqlajax_genxml.php", function(data) { var xml = data.responseXML; 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 }); 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) { var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest; request.onreadystatechange = function() { if (request.readyState == 4) { request.onreadystatechange = doNothing; callback(request, request.status); } }; request.open('GET', url, true); request.send(null); } function doNothing() {} //]]>

Solutions Collecting From Web of "Google Maps API in WordPress"