plaidpancakes
plaidpancakes

Reputation: 119

google maps not loading, showing just a '

So im using PHP/MySQL to load the information into a XML which works then I have this code below that is supposed to make the map and load the xml and plug it into the markers when clicked. This is almost 100% copy pasted from googles tutorial

https://developers.google.com/maps/articles/phpsqlajax_v3#createmap

Any help would be lovely I have been struggling with this for days

<!DOCTYPE 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.googleapis.com/maps/api/js?key=my           key&sensor=true"></script>
    <script type="text/javascript">
     //<![CDATA[


    function load() {
      var map = new google.maps.Map(document.getElementById("map"), {
       center: new google.maps.LatLng('34.153471', '-118.432123'),
    zoom: 13,
    mapTypeId: 'roadmap'
  });
  var infoWindow = new google.maps.InfoWindow;

  // Change this depending on the name of your PHP file
  downloadUrl("mapXML2.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 desc = markers[i].getAttribute("desc");
            var cap = markers[i].getAttribute("eventcap");
            var cur = markers[i].getAttribute("eventcur");
            var type = markers[i].getAttribute("type");
            var point = new google.maps.LatLng(
                parseFloat(markers[i].getAttribute("lat")),
                parseFloat(markers[i].getAttribute("lng")));
            var html = "<b>" + name + "</b> <br/>" + address + "<br/>" + desc + "<br/>" + "Currently " + cur + "/" + cap;
            //var icon = customIcons[type] || {};
            var marker = new google.maps.Marker({
                map: map,
                position: point
            });
            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() {}

    //]]>

  </script>

  </head>

  <body onload="load()">
    <div id="map" style="width: 500px; height: 300px"></div>
  </body>

</html>

Upvotes: 0

Views: 254

Answers (1)

david strachan
david strachan

Reputation: 7228

You are missing closing bracket for load()

        }
    });
}//**ADD THIS**
function bindInfoWindow(marker, map, infoWindow, html) {

Upvotes: 1

Related Questions