Aller au contenu

weboblog

Membre
  • Compteur de contenus

    2
  • Inscrit(e) le

  • Dernière visite

Messages postés par weboblog

  1. Bonjour Diving-Seller,

    J'ai regardé un peu ton code et voici quelques commentaires / actions qui pourraient résoudre ton problème :

    1_ Déclarer ta map avec tes variables globales: var map;

    et conserver son instanciation dans ta fonction load: map = new google.maps.Map(document.getElementById("map"), options);

    Cette première étape t'évitera de passer la variable "map" à tes fonctions, notamment l'appel à ta fonction "bindInfoWindow".

    2_ Ajouter 2 variables globales, à savoir :

    var html = [];

    var m = 0;

    3_ Remplacer html = nom + type + notation + level + prof + gps par html[m] = nom + type + notation + level + prof + gps;

    4_ Remplacer :

    var marqueur = new google.maps.Marker({

    map: map,

    position: point,

    icon: icon.icon

    });

    Par

    var marqueur = new google.maps.Marker({

    map: map,

    position: point,

    infobulle : html[m],

    icon: icon.icon

    });

    5_ Remplacer :

    tableaumarqueurs=marqueur;

    bindInfoWindow(marqueur, map, infoWindow, html);

    contenuListe += '<li><a href="javascript:bindInfoWindow(marqueur,map,infoWindow,html)">' + nom +'</a></li>';

    Par

    tableaumarqueurs.push(marqueur);

    google.maps.event.addListener(marqueur, 'click', function() {

    infoWindow.setContent(this.infobulle);

    map.setCenter(this.position);

    infoWindow.open(map, this);

    });

    contenuListe += '<li><a href="javascript:bindInfoWindow('+m+')">' + nom +'</a></li>';

    6_ Modifier ta fonction bindInfoWindow comme ci-dessous:

    function bindInfoWindow(m) {

    infoWindow.setContent(html[m]);

    map.setCenter(tableaumarqueurs[m].position);

    infoWindow.open(map, tableaumarqueurs[m]);

    }

    Pour information, tu peux aussi sortir la création de ton marker "ILE" de la boucle en le mettant avant par exemple.

    Cdlt,

×
×
  • Créer...