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

JavaScript Discussion :

google map api


Sujet :

JavaScript

Vue hybride

Message pr�c�dent Message pr�c�dent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Profil pro
    Inscrit en
    D�cembre 2006
    Messages
    1
    D�tails du profil
    Informations personnelles :
    �ge : 40
    Localisation : France

    Informations forums :
    Inscription : D�cembre 2006
    Messages : 1
    Par d�faut google map api
    bonjour
    voila mon probleme je veux afficher plusieur point sur une carte en fonctions des coordonn�es (lat, lng)
    ces coordonn�es sont dans une base de donn�e mysql
    le probleme est que lorsque j'affiche ma carte j'obtient uniquement le dernier point de ma base de donn�e alors que je voudrai que tout les point soit afficher

    voila mon code


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>

    <?php
    mysql_connect("", "", "");
    mysql_select_db("");

    //on recupere la latitude longitude nom de la structure
    $reponse = mysql_query("SELECT Latitude,Longitude FROM T_Gps")

    while ($donnees = mysql_fetch_array($reponse)){


    ?>

    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>carte d'essai</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key="
    type="text/javascript"></script>
    <script type="text/javascript">

    //<![CDATA[
    function load() {
    if (GBrowserIsCompatible()) {

    function createMarker(point, number) {
    var marker = new GMarker(point,icon);
    GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowTabsHtml(infoTabs);
    });
    return marker;
    }
    var infoTabs = [
    new GInfoWindowTab(" info1", " "),
    new GInfoWindowTab(" info2", " ")
    ];

    //cr�ation d'une carte nomm� "map"
    var map = new GMap2(document.getElementById("map"));
    GEvent.addListener(map, "moveend", function() {

    var center = map.getCenter();
    });

    map.addControl(new GSmallMapControl());

    map.addControl(new GMapTypeControl());


    map.setCenter(new GLatLng(45.44 , 4.395), Cool;


    var icon = new GIcon();

    icon.image = "http://images.google.fr/images?q=tbn:gS51abIJ6eysoM:http://rgfrance0.tripod.com/sitebuildercontent/sitebuilderpictures/flag.jpg";

    icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";

    icon.iconSize = new GSize(23, 23);
    icon.shadowSize = new GSize(22, 20);
    icon.iconAnchor = new GPoint(6, 20);
    icon.infoWindowAnchor = new GPoint(5, 1);



    var point = new GLatLng('<?php echo $donnees['Latitude']; ?>','<?php echo $donnees['Longitude'] ; ?>')
    map.addOverlay(createMarker(point ,1));
    marker.openInfoWindowTabsHtml(infoTabs);

    }
    }

    //]]>
    </script>
    <?php
    }
    mysql_close();
    ?>
    </head>
    <body onload="load()" onunload="GUnload()">
    <div id="map" style="width: 500px; height: 500px"></div>
    </body>
    </html>


    voila merci d'avance pour vos reponse

  2. #2
    Membre Expert
    Profil pro
    Inscrit en
    Mai 2004
    Messages
    1 252
    D�tails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Mai 2004
    Messages : 1 252
    Par d�faut
    Bon, primo, va falloir regrouper tout ton PHP en un seul endroit. Tu verras, �a ira dix fois mieux.

    Ensuite, j'ai refait ton code. J'ai pas tout compris alors, j'ai tout indent� correctement, mis le PHP en d�but de code et appel� les variables PHP lorsque c'�tait n�cessaire.

    Ton probl�me �tait que tu appelais une fois le JavaScript par tuple dans ta base de donn�es. Alors, bien �videmment, un seul load �tait appel�, et pas les X que tu tentes d'instancier.

    Sinon, je n'ai pas test� le code, mais � priori, il devrait �tre bon. Si tu as davantages de probl�mes, continue le post ci-dessous

    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
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    <?php
     
    mysql_connect("", "", "");
    mysql_select_db("");
     
    $reponse = mysql_query("SELECT Latitude,Longitude FROM T_Gps")
     
    $data = array();
     
    while ($donnees = mysql_fetch_array($reponse)){
      $data[] = $donnees;
    }
     
    mysql_close();
     
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <title>carte d&apos;essai</title>
        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=" type="text/javascript"></script>
        <script type="text/javascript">
          //<![CDATA[
          function load() {
            if (GBrowserIsCompatible()) {
              function createMarker(point, number) {
                var marker = new GMarker(point,icon);
                GEvent.addListener(marker, "click", function() {
                    marker.openInfoWindowTabsHtml(infoTabs);
                  });
                return marker;
              }
              var infoTabs = [
                  new GInfoWindowTab(" info1", " "),
                  new GInfoWindowTab(" info2", " ")
                ];
     
              //création d'une carte nommé "map"
              var map = new GMap2(document.getElementById("map"));
              GEvent.addListener(map, "moveend", function() {
                  var center = map.getCenter();
                });
     
              map.addControl(new GSmallMapControl());
              map.addControl(new GMapTypeControl());
              map.setCenter(new GLatLng(45.44 , 4.395), Cool;
     
              var icon = new GIcon();
              icon.image = "http://images.google.fr/images?q=tbn:gS51abIJ6eysoM:http://rgfrance0.tripod.com/sitebuildercontent/sitebuilderpictures/flag.jpg";
              icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
              icon.iconSize = new GSize(23, 23);
              icon.shadowSize = new GSize(22, 20);
              icon.iconAnchor = new GPoint(6, 20);
              icon.infoWindowAnchor = new GPoint(5, 1);
     
    <?php foreach ($data as $donnees): ?>
              var point = new GLatLng('<?php echo $donnees['Latitude']; ?>','<?php echo $donnees['Longitude'] ; ?>')
              map.addOverlay(createMarker(point ,1));
    <?php endforeach;  ?>
     
              marker.openInfoWindowTabsHtml(infoTabs);
            } // fin if (GBrowserIsCompatible())
          } // fin load()
          //]]>
        </script>
      </head>
      <body onload="load()" onunload="GUnload()">
        <div id="map" style="width: 500px; height: 500px"></div>
      </body>
    </html>
    P.S. Je ne sais pas du tout ce que fait la derni�re ligne JavaScript, mais � priori, elle ne fait rien et risque de te poser probl�me.

+ R�pondre � la discussion
Cette discussion est r�solue.

Discussions similaires

  1. Google map API
    Par rudylar dans le forum G�n�ral JavaScript
    R�ponses: 0
    Dernier message: 02/07/2008, 18h53
  2. google map api
    Par debutantasp dans le forum G�n�ral JavaScript
    R�ponses: 6
    Dernier message: 30/05/2008, 14h02
  3. Google Map - API Java ?
    Par onlytoine dans le forum Collection et Stream
    R�ponses: 3
    Dernier message: 28/04/2008, 11h25
  4. Utilisation de la Google Maps API ?
    Par [ZiP] dans le forum Web & r�seau
    R�ponses: 4
    Dernier message: 04/09/2007, 22h26
  5. Google Map API --> Javascript et code behind C#
    Par bridel dans le forum ASP.NET
    R�ponses: 2
    Dernier message: 22/01/2007, 21h07

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