Question

Je me bats en essayant de regrouper 50 marqueurs en utilisant la MarkerClusterer v3 avec Google maps API v3.

J'ai suivi l'exemple simple à l'adresse: http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/docs/examples.html pour construire ma fonction mais quand la carte I est chargé reçois l'erreur suivante dans firebug:

a is undefined
Ba(H,function(a){if(!a)return l;return...){return new P(this.T.d,this.P.b,i)}; main.js (line 13)

Ma fonction est en train de faire un simple appel JSON pour obtenir le point à partir du serveur, puis construire le tableau des marqueurs avant de les ajouter à la MarkerClusterer.

function addMarkerCluster(){
    //get json data and create array of map markers and mark up the map using
    //a map cluster

    $.getJSON("feed/kml.php?action=json",
        function(data){

            var map;
            var markers = [];

            var latlng = new google.maps.LatLng(24.91654, 15.31326);

            var myOptions = {
                zoom: 3,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.HYBRID

            };
            map = new google.maps.Map(document.getElementById("googlemap"), myOptions);

            google.maps.event.addListener(map, "tilesloaded", function(){
                attachFancyBox();
                hideLoadDialog();
            });


            //loop through the data and add to the markers array the lat/lng of the centerpoints
            //as google lat/lng objects.
            $.each(data, function(i){

                latlng = new google.maps.LatLng(this.lat, this.lng);
                var marker = new google.maps.Marker(latlng);

                markers.push(marker);

            });



            var markerCluster = new MarkerClusterer(map, markers);


        });


}

Toute idée pourquoi cela est à l'origine de la carte Google main.js à l'échec de cette façon? Si je viens d'ajouter le MarkerClusterer sans le tableau de marqueurs de la carte sans erreur rend.

Quand j'ajoute le tableau de marqueurs puis les erreurs de carte.

Merci,

Grant

Était-ce utile?

La solution

Fix était simple je manquerais le fait que les besoins google maps api v3 pour avoir un objet qui lui est passé. Le correctif a été de changer

var marker = new google.maps.Marker(latlng) 
to
var marker = new google.maps.Marker({'position' : latlng});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top