Ok, that's it !

Now, the first 'GDownloadUrl' launches the second 'GDownloadUrl'. And
it works each time.
I keep my $(document).ready(function (){}) moreover.

Thanks for your help.

Here is the new code.

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

        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);

        // 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);
                //if(i==22){alert('fin traitement categories');}
            }

            downloadThen();
        });

        function downloadThen() {
                // 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