0

I had my Google map running just fine. I've been trying to get only one infowindow to open at once and in the process of doing that, broke my code. I am unable to get it back to a working stage at this point. I've gone through the code a dozen times and can't find anything wrong with it. I was basing my changes on this article on the stackoverflow forums.

<script type="text/javascript">

    function initialize() {
        var infowindow new google.maps.InfoWindow();
        var LatLng = new google.maps.LatLng(38.89, -92.343);
        var myOptions = {
            zoom: 13,
            mapTypeId: google.maps.MapTypeId.ROADMAP,
            center: LatLng
        };

        var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

        var bounds = new google.maps.LatLngBounds();    

        var Image = "images/wrenchIcon.png";
        var Content = "blank";
        var Head = "The Falls";

        var cMarker = new google.maps.Marker({
            position: LatLng,
            map: map,
            title: Head,
            icon: Image
        })

        google.maps.event.addListenter(cMarker, 'click', function() {
            infowindow.setContent(Content);
            infowindow.open(map, cMarker);
        });

            Image = "images/goodIcon.png";

            LatLng = new google.maps.LatLng(38.912, -92.301);
            Content = "blank";
            Head = "Bob TheBuilder";

            var marker1 = new google.maps.Marker({
                position: LatLng,
                map: map,
                title: Head,
                icon: Image
            });

            google.maps.event.addListenter(marker1, 'click', function() {
                infowindow.setContent(Content);
                infowindow.open(map, marker1);
            });     

            bounds.extend(LatLng);

            Image = "images/alertYelIcon.png";

            LatLng = new google.maps.LatLng(38.951, -92.332);
            Content = "blank";
            Head = "Shiloh Bar&Grill";

            var marker2 = new google.maps.Marker({
                position: LatLng,
                map: map,
                title: Head,
                icon: Image
            });

            google.maps.event.addListenter(marker2, 'click', function() {
                infowindow.setContent(Content);
                infowindow.open(map, marker2);
            });     

            bounds.extend(LatLng);

            Image = "images/goodIcon.png";

            LatLng = new google.maps.LatLng(38.92, -92.332);
            Content = "blank";
            Head = "FlatBranch Pub";

            var marker3 = new google.maps.Marker({
                position: LatLng,
                map: map,
                title: Head,
                icon: Image
            });

            google.maps.event.addListenter(marker3, 'click', function() {
                infowindow.setContent(Content);
                infowindow.open(map, marker3);
            });     

            bounds.extend(LatLng);
</script>
Community
  • 1
  • 1
atk3kf
  • 3
  • 2
  • I know this post is very specific but anything you could do would help, I'm to the point of banging my head against the wall. – atk3kf Aug 30 '11 at 19:31

2 Answers2

0

It looks like your initialize function doesn't have a closing } If this isn't the issue when is the function being called, onload?

tomfumb
  • 3,669
  • 3
  • 34
  • 50
  • I put the closing bracket in but it still won't load. I noticed that sometimes there will be a grey outline where the map should be if it doesn't load and other times there's nothing. With this particular problem there is nothing. In the next few lines after the javascript is the body tag `` – atk3kf Aug 30 '11 at 19:53
  • then I suggest you double check there is 1 (and only 1) div with the id "map_canvas" and then paste your js (minus – tomfumb Aug 30 '11 at 20:03
  • Thank you for the link. I've been looking for a reliable site to check my javascript, I'm fairly new to it. – atk3kf Aug 30 '11 at 20:09
0

It also looks like you're missing a = in the first line of the initialize function.

  • Of course. I just realized how long I've been looking at this code with that error staring me in the face. – atk3kf Aug 30 '11 at 20:11