IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

APIs Google Discussion :

plusieur marker et infobulle


Sujet :

APIs Google

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    265
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2009
    Messages : 265
    Par défaut plusieur marker et infobulle
    Bonjour

    j'ai une base de données avec plusieurs coordonnées gps, j'arrive bien a afficher tous les markers sans souci, par contre concernant l'infobulle, ca ne va pas, l'infobulle ne s'affiche que sur le premier marker, quelque soit le marker sur lequel on clique.

    je seche un peu..

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
     
         function initialize() {
           if (GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById('map'));
            map.setCenter(new GLatLng(47.3850790,-1.0299580),8);
            map.addControl(new GMapTypeControl());
            map.removeMapType(G_HYBRID_MAP);
            map.addMapType(G_PHYSICAL_MAP);
            map.setMapType(G_PHYSICAL_MAP);
            map.addControl(new GOverviewMapControl());
            map.addControl(new GScaleControl());
            map.addControl(new GLargeMapControl());
            map.enableScrollWheelZoom();
           var urlstr = "ajax.php";
           GDownloadUrl(urlstr, function(data) {
             var xml = GXml.parse(data);
             var markers = xml.documentElement.getElementsByTagName("marker");
             for (var i = 0; i < markers.length; i++) {
               var nom = markers[i].getAttribute("nom");
               var text = markers[i].getAttribute("lat");
               var color = markers[i].getAttribute("color");
               var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("long")));
               var title = "mon titre";
              var iconOptions = {};
              iconOptions.width = 32;
              iconOptions.height = 32;
              iconOptions.primaryColor = color;
              iconOptions.cornerColor = "#FFFFFF";
              iconOptions.strokeColor = "#A5A5A5";
              var icon = MapIconMaker.createMarkerIcon(iconOptions);
               var marker = new GMarker(point, icon);
                GEvent.addListener(marker, "click", function() {
                        var tab1 = new GInfoWindowTab("Titre", "<div>titre<\/div>");
                        var infoTabs = [tab1];
                        marker.openInfoWindowTabsHtml(infoTabs);
                    });
     
     
               map.addOverlay(marker);       
             }  
           });
          }  
          else{
           alert('Désolé, mais votre navigateur n\'est pas compatible avec Google Maps');
          }
        }
    si quelqu'un avait une idée pour que l'infobulle s'affiche bien sur chaque marker..

    Merci

  2. #2
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 242
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 242
    Par défaut
    Bonsoir,
    je ne saurais que te suggérer de passer à la V3.x

    Citation Envoyé par Google Maps JavaScript API V2 Reference
    Note: The Google Maps Javascript API Version 3 documented within these pages is now the official Javascript API. Version 2 of this API has been officially deprecated as per our deprecation policy. We encourage you to migrate your code to this newly updated and enhanced version!
    Pour en revenir à ton probléme il est expliqué/traité dans la http://javascript.developpez.com/faq...wDernierMarker
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    GEvent.addListener(marker, "click", function () {
      var tab1 = new GInfoWindowTab("Titre", "<div>titre<\/div>");
      var infoTabs = [tab1];
      // marker.openInfoWindowTabsHtml(infoTabs);
      this.openInfoWindowTabsHtml(infoTabs); // ICI utilisation de this
    });

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    265
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2009
    Messages : 265
    Par défaut
    merci de ta réponse.

    alors, ca fonctionne bien pour l'ouverture de la pop up, par contre, ca affiche toujours le meme nom, alors que cela devrait afficher le nom de chaque point...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
     
     function initialize() {
           if (GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById('map'));
            map.setCenter(new GLatLng(47.3850790,-1.0299580),8);
            map.addControl(new GMapTypeControl());
            map.removeMapType(G_HYBRID_MAP);
            map.addMapType(G_PHYSICAL_MAP);
            map.setMapType(G_PHYSICAL_MAP);
            map.addControl(new GOverviewMapControl());
            map.addControl(new GScaleControl());
            map.addControl(new GLargeMapControl());
            map.enableScrollWheelZoom();
           var urlstr = "ajax.php";
           GDownloadUrl(urlstr, function(data) {
             var xml = GXml.parse(data);
             var markers = xml.documentElement.getElementsByTagName("marker");
             for (var i = 0; i < markers.length; i++) {
               var nom = markers[i].getAttribute("nom");
               var text = markers[i].getAttribute("lat");
               var color = markers[i].getAttribute("color");
               var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),parseFloat(markers[i].getAttribute("long")));
              var iconOptions = {};
              iconOptions.width = 32;
              iconOptions.height = 32;
              iconOptions.primaryColor = color;
              iconOptions.cornerColor = "#FFFFFF";
              iconOptions.strokeColor = "#A5A5A5";
              var icon = MapIconMaker.createMarkerIcon(iconOptions);
     
              var marker = new GMarker(point, icon); 
              GEvent.addListener(marker, "click", function () {
              var tab1 = new GInfoWindowTab("Titre", nom);
              var infoTabs = [tab1];
      // marker.openInfoWindowTabsHtml(infoTabs);
             this.openInfoWindowTabsHtml(infoTabs); // ICI utilisation de this
    });
     
     
               map.addOverlay(marker);       
             }  
           });
          }  
          else{
           alert('Désolé, mais votre navigateur n\'est pas compatible avec Google Maps');
          }
        }
      </script>

  4. #4
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 242
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 242
    Par défaut
    ton problème est décrit, toujours dans la http://javascript.developpez.com/faq...owBonAffichage, à adapter à ta version de Google Map.

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Mai 2009
    Messages
    265
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2009
    Messages : 265
    Par défaut
    malheureusement le javascript et moi.. ca fait deux

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
      var marker = new GMarker(point, icon); 
              GEvent.addListener(marker, "click", function () {
             var tab1 =new GInfoWindowTab ("Titre", nom);
              var infoTabs = [tab1];
      // marker.openInfoWindowTabsHtml(infoTabs);
             this.openInfoWindowTabsHtml(infoTabs); // ICI utilisation de this
    });
    j'ai tenter
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     var marker = new GMarker[i](point, icon);
    pour récuperer les infos, mais ca plante.

    je suis completement paumé.. mettre this derriere le code ne donne rien non plus..

  6. #6
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 242
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 242
    Par défaut
    malheureusement le javascript et moi.. ca fait deux
    cela ne doit pas être une fatalité...
    Citation Envoyé par groskanel Voir le message
    j'ai tenter
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     var marker = new GMarker[i](point, icon);
    pour récuperer les infos, mais ca plante.
    il ne faut pas faire n'importe quoi non plus, GMarker est un constructeur défini dans l'API V2, ce n'est aucunement un Array.

    A partir du lien que je t'ai mis et en suivant les liens on tombe sur http://javascript.developpez.com/faq...indowAffichage, et là 3 solutions te sont proposées.

Discussions similaires

  1. [Google Maps] Affichage de map avec plusieurs markers et une InfoWindow par marker
    Par yesenia dans le forum APIs Google
    Réponses: 5
    Dernier message: 20/12/2016, 15h53
  2. [Google Maps] afficher plusieurs marker sur une carte
    Par l'coy dans le forum APIs Google
    Réponses: 7
    Dernier message: 24/04/2011, 08h32
  3. Ajouter plusieurs markers dans un ItemizedOverlay.
    Par KaiserQ dans le forum Android
    Réponses: 11
    Dernier message: 04/12/2010, 23h51
  4. Plusieurs markers mais n'afficher qu'un seul infowindow
    Par luan220 dans le forum APIs Google
    Réponses: 0
    Dernier message: 12/08/2010, 02h05
  5. génération dynamique de marker et infobulle
    Par Sylvain__A_ dans le forum APIs Google
    Réponses: 3
    Dernier message: 26/04/2009, 17h32

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo