Stremegborn
New Member
Im trying to do this tutorial on http://www.geocodezip.com/v3_SO_multipleGeocodedMarkersFromXml.htmlI have included the downloadxml.js on my server but it still doesnt work. The map loads up but no map markers. Can anyone help as I cant see why it wont work.\[code\]<!DOCTYPE html><html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8" /><title>Google Maps Multiple Markers</title><script src="http://maps.google.com/maps/api/js?sensor=false"type="text/javascript"></script><script type="text/javascript" src="http://stackoverflow.com/questions/15664395/scripts/downloadxml.js"></script><script type="text/javascript">var map = null;var geocoder = new google.maps.Geocoder();var info_window = new google.maps.InfoWindow();var bounds = new google.maps.LatLngBounds();geocodeAddress(xmldata){ var address = xmldata.getElementsByTagName('address')[0].firstChild.data; var city = xmldata.getElementsByTagName('city')[0].firstChild.data; var address_google_map = address + ', ' + city + ', ON'; var info_text = address + '<br />' + city + ' ON'; geocoder.geocode ({'address': address_google_map}, function (results, status) { if (status == google.maps.GeocoderStatus.OK) { createMarker(results[0].geometry.location, info_text); } else { alert("geocode of "+ address +" failed:"+status); } }); } function createMarker(latlng, html){ var marker = new google.maps.Marker ({ map: map, position: latlng }); google.maps.event.addListener(marker, 'click', function() { info_window.setContent(html); info_window.open(map, marker); });}function initialize (){var myLatLng = new google.maps.LatLng(45.2340684, -75.6287287);var myOptions ={ zoom: 10, mapTypeControl: true, center: myLatLng, zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.SMALL }, StreetViewControl: false, mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById('map'), myOptions); google.maps.event.addListener (map, 'click', function () { info_window.close(); }); downloadUrl('listings.xml', function (listings_data) { listings_data = http://stackoverflow.com/questions/15664395/xmlParse(listings_data); var markers = listings_data.documentElement.getElementsByTagName('listing'); var geocoder = new google.maps.Geocoder(); for (var i = 0; i < markers.length; i++){geocodeAddress(markers);}google.maps.event.addListenerOnce(map, 'idle', function() {map.fitBounds(bounds);});});}</script></head><body onload="initialize();"><div id="map" style="width: 500px; height: 400px;"></div></body></html>\[/code\]and my XML\[code\]<?xml version="1.0" encoding="UTF-8"?><listings><listing><address>4123 Rideau Valley Rd</address><city>MANOTICK</city></listing><listing><address>4456 Rideau Valley Rd</address><city>MANOTICK</city></listing><listing><address>111 Bridge St</address><city>MANOTICK</city></listing><listing><address>777 Bridge St</address><city>Ottawa</city></listing><listing><address>1333 Bridge Street</address><city>Manotick</city></listing></listings>\[/code\]