Google maps infowindow doesnt show up anymore

Good morning,

A former colleague of mine had created an application where you could search by zipcode and then placed markers on the map (google maps) in a radius of 5-40 km.

The locations are stores in a radius of 40 km from the zip code where you are looking for. The function itself is still working only the info window with the information does not work anymore.

I have several websites running with this application but for all sites the infowindow is not working anymore. Could it be that Google itself has made ​​adjustments in the api and I also need to adjust something somewhere?

This is the code that my colleague has put together and there is nothing changed but it does not work anymore ... Is there someone here know anything about the problem because I can not figure out myself..

    <script type="text/javascript">
                        var geocoder;
                        var map;
                        function initialize() {
                            geocoder = new google.maps.Geocoder();
                            var myOptions = {
                                zoom: <?php
                                if(is_array($postcodevelden) && count($postcodevelden) > 0 && !empty($_POST['address']))
                                {
                                    switch($radius)
                                    {
                                        case "5":
                                            echo "12";
                                            break;
                                        case "10":
                                            echo "11";
                                            break;
                                        case "15":
                                        case "20":
                                            echo "10";
                                            break;
                                        case "30":
                                        case "40":
                                            echo "9";
                                            break;
                                    }
                                }
                                else
                                {
                                    echo "7";
                                }
                                ?>,
                                center: new google.maps.LatLng(<?php if(is_array($postcodevelden) && count($postcodevelden) > 0) { echo $lat.", ".$lon; } else { echo "52.2008737173322, 5.25146484375"; } ?>),
                                mapTypeId: google.maps.MapTypeId.ROADMAP
                            }
                            map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

<?php
        if(is_array($adressen) AND count($adressen) > 0) 
        {
            foreach($adressen as $adres)
            {
                $afstand = round((6371 * acos(sin(deg2rad($lat)) * sin(deg2rad($adres->locatie_lat)) + cos(deg2rad($lat)) * cos(deg2rad($adres->locatie_lat)) * cos(deg2rad($adres->locatie_lon) - (deg2rad($lon))))), 2);
?>
                            addMarker(<?php echo $adres->locatie_lat.", ".$adres->locatie_lon.", '".$adres->locatie_naam."', '".$adres->locatie_straat."', '".$adres->locatie_postcode."', '".$adres->locatie_plaats."', '".$adres->locatie_telefoon."', '".$afstand."'"; ?>);
<?php
            }
        }
?>
                        }

                        var infowindow = new google.maps.InfoWindow();

                        function addMarker(lat, lon, naam, straat, postcode, plaats, telefoon, afstand)
                        {
                            var marker = new google.maps.Marker({
                                position: new google.maps.LatLng(lat, lon),
                                map: map,
                                icon: "images/pincard/wheel-icon.png",
                                title: naam
                            });

                            google.maps.event.addListener(marker, 'mouseover', function() {
                                var contentString = '<div>'+
                                '<b style="border-bottom: 1px solid #000000;">' + naam + '</b><br/>'+
                                'Afstand (hemelsbreed): ' + afstand + ' km<br/>' +
                                straat + '<br/>' +
                                postcode + ' ' + plaats + '<br/>';
                                if(telefoon != "")
                                {
                                    contentString = contentString + 'Telefoonnr: ' + telefoon;
                                }
                                contentString = contentString + '</div>';
                                infowindow.content = contentString;
                                infowindow.open(map, marker);
                            });

                            google.maps.event.addListener(marker, 'mouseout', function(){
                                infowindow.close(map);
                            });
                        }

                        google.maps.event.addDomListener(window, 'load', initialize);
                    </script>

I call the api like this:

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

If anyone has any idea why the info window to all websites stops working then I would love to hear that because I do not understand why it no longer works.

Thanks in advance for any effort

Kind regards,

Joep

PS: this is a website for example:

intertyre...php?lang=nl&p=4


I was bitten by the same problem and went Googling for an answer.

Found the answer to my problem -- it looks like Google may have tightened up its infoWindow API a bit forcing you to set the .content member via a proper Set() function.

Try replacing the line

infowindow.content = contentString;

with

infowindow.setContent(contentString);

and see if that helps. I did that with my code and that fixed the breakage.

链接地址: http://www.djcxy.com/p/6090.html

上一篇: NPI查找API免费提供

下一篇: 谷歌地图infowindow不再显示