I have tested without using jQuery which launches the script only when
the DOM has finished loading.
Unfortunately, it does not work better. Sometimes markers, sometimes
not...

My code structure is the same as yours. (see it below)
I will wait to see it in action online.

if (GBrowserIsCompatible()) {
        var markerGroups = [];
        var pictosFleuveRhone = [];
        var center = new GLatLng(44.824708282300236, 5.25146484375);
        var zoom_level = 8;

        function showMapCenter() {
            var new_center = map.getCenter();
            alert(new_center.toString());
        }

        function createMarker(point, name, label, type, detail) {
            var marker = new LabeledMarker(point, {icon:
pictosFleuveRhone[type]});
            markerGroups[type].push(marker);
            var html = "<strong>" + name + "</strong> <br/>"+detail;
            GEvent.addListener(marker, 'click', function() {
                marker.openInfoWindowHtml(html);
            });
            return marker;
        }

        function toggleGroup() {
            var btn=$(this);
            var type=btn.attr('id');
            var css_class=btn.attr('class');

            if (css_class == 'actif') {
                btn.removeAttr('class');
            } else {
                btn.addClass('actif');
            }

            for (var i = 0; i < markerGroups[type].length; i++) {
                var marker = markerGroups[type][i];
                if (marker.isHidden()) {
                    marker.show();
                } else {
                    marker.hide();
                }
            }
        }

        var map = new GMap2(document.getElementById("map_canvas"));
        map.addMapType(G_PHYSICAL_MAP);
        map.setCenter(center, zoom_level, G_PHYSICAL_MAP);

        var customUI = map.getDefaultUI();
        customUI.zoom.scrollwheel = true;
        map.setUI(customUI);

        /*GEvent.addListener(map, "moveend", function(){
            showMapCenter();
        });*/

        // Récupération des catégories pour constituer les groupes de
points
        // On récupère également le picto
        GDownloadUrl("/gmapdata/list/245/listCategories/categories",
function(data){
            var xml = GXml.parse(data);
            var categories = xml.documentElement.getElementsByTagName
("categorie");

            for (var i = 0; i < categories.length; i++) {
                // Constitution du groupe
                var cat_id=categories[i].getAttribute("id");
                markerGroups[cat_id] = [];
                $("a#"+cat_id).click(toggleGroup);

                // Constitution du picto
                pictosFleuveRhone[cat_id] = new GIcon();
                pictosFleuveRhone[cat_id].image = categories
[i].getAttribute("picto");
                pictosFleuveRhone[cat_id].iconSize = new GSize(20,
20);
                pictosFleuveRhone[cat_id].iconAnchor = new GPoint(16,
16);
                pictosFleuveRhone[cat_id].infoWindowAnchor = new GPoint
(5, 1);
                pictosFleuveRhone[cat_id].shadow = '';
                pictosFleuveRhone[cat_id].shadowSize = new GSize(22,
20);
            }
        });

        // Récupération des lieux
        GDownloadUrl("/gmapdata/list/197/listLocation/mapitem",
function(data){
            var xml = GXml.parse(data);
            var markers = xml.documentElement.getElementsByTagName
("marker");

            for (var i = 0; i < markers.length; i++) {
                var name = markers[i].getAttribute("name");
                var detail = markers[i].getAttribute("detail");
                var label = i;
                var type = markers[i].getAttribute("type_id");
                var point = new GLatLng(parseFloat(markers
[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")));
                var marker = createMarker(point, name, label, type,
detail);
                map.addOverlay(marker);
            }
        });
    }

--

You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api?hl=en.


Reply via email to