Карты Google - не отображаются, но загружены в HTML - PullRequest
0 голосов
/ 13 июля 2010

Я не знаю, почему это так.

Но по какой-то причине мой скрипт Google Maps загружается на страницу, но не отображается.

Мне любопытно, что я делаю неправильно.

Вот мой HTML.

<ul class="address">
<LI><STRONG>Titel:</STRONG><br/>Text
<div class="gmap" address="Stationsstraat 23 8780 Oostrozebeke"></div></LI>
</ul>
<ul class="address">
<LI><STRONG>Titel:</STRONG>Text
<div class="gmap" address="Eredekestraat 56 2000 Antwerpen"></div></LI></UL>

А вот мой Javascript (с jQuery):

     $(document).ready(function(){
        var coll_gmap = $(".gmap");
        if ( coll_gmap.length != 0 )
        {
            //initiate map
            geocoder = new google.maps.Geocoder();
            var latlng = new google.maps.LatLng(-34.397, 150.644);
            var myOptions = {
                zoom: 8,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            }

            //loop all addressen + insert into map
            coll_gmap.each(function(index)
            {
                map = new google.maps.Map(coll_gmap[0], myOptions);
                 if (geocoder) {
                        geocoder.geocode( { 'address': $(this).attr("address")}, function(results, status) {
                            if (status == google.maps.GeocoderStatus.OK) {
                                map.setCenter(results[0].geometry.location);
                                var marker = new google.maps.Marker({
                                    map: map, 
                                    position: results[0].geometry.location
                                });
                            } else {
                                alert("Geocode was not successful for the following reason: " + status);
                            }//end if status
                        }); //end if geocoder.geocode
                    } //end if geocoder   

            }) //end coll_gmap each

            }//end if coll_gmap length
    }); //end onload


    var geocoder, map;

Ответы [ 2 ]

3 голосов
/ 13 июля 2010

Я узнал, что это было.

Я должен установить ширину и высоту на

<div> =>(becomes)=>
<div style="width:500px;height:150px"></div> 

Просто забыть, наверное: (

2 голосов
/ 13 июля 2010

битый HTML. Ни один из ваших div'ов не закрыт, и это совершенно неправильно: </ </LI></UL>

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...