开发者

Google Maps: made changes, now map won't load

开发者 https://www.devze.com 2023-04-01 20:25 出处:网络
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

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 = {开发者_如何学JAVA
            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>


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消