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 :

Utilisation de GEvent.addlistener [Google Maps]


Sujet :

APIs Google

  1. #1
    Membre éclairé Avatar de thierrybatlle
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Novembre 2005
    Messages
    621
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 55
    Localisation : France, Tarn (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Enseignement

    Informations forums :
    Inscription : Novembre 2005
    Messages : 621
    Par défaut Utilisation de GEvent.addlistener
    Bonjour à tous,

    J'ai ce code :
    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
     
    <!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=iso-8859-1"/>
       <title>Utilisation de XML</title>
        <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAFhJ6OnZIlZXbu_0iBMpJTxTK3GXfY_0lkgcH9BkNB1ukiq8r6hSL6OWX2CwCiH9TR7_ms5MHiT--dA"
     
                 type="text/javascript"></script>
            <script type="text/javascript">
           //<![CDATA[
     
           function load() {
             if (GBrowserIsCompatible()) {
              var map = new GMap2(document.getElementById("map"));
               map.addControl(new GSmallMapControl());
               map.addControl(new GMapTypeControl());
               map.setCenter(new GLatLng(48.7, 2.3), 8);
     
           function creerMarker(point, onglet1, onglet2, iconePerso) {
     
            // Test de changement d icones /////////////////////////////////////////////////////////////
            var monIcone = new GIcon();
            //monIcone.shadow = "mesImages/coffeehouse-s.png";
            //monIcone.shadowSize = new GSize(56,32);
            monIcone.iconSize = new GSize(32,19);
            monIcone.iconAnchor = new GPoint(16,32);
            monIcone.image = iconePerso;
            ////////////////////////////////////////////////////////////////////////////////////////////
     
            var marker = new GMarker(point,monIcone);
             //var infoTabs = [
             var tab1 = new GInfoWindowTab("Infos", "toto");
             var tab2 = new GInfoWindowTab("Details", "titi");
             // ];
             GEvent.addListener(marker, "click", function() {
               marker.openInfoWindowHtml("Coucou");
               });
             return marker;
             }
     
               GDownloadUrl("http://virginie-et-thierry.fr/cartes/donnees.xml", function(data) {
                 var xml = GXml.parse(data);
                 var markers = xml.documentElement.getElementsByTagName("marker");
                 for (var i = 0; i < markers.length; i++) {
                   var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")), parseFloat(markers[i].getAttribute("lng")), 9);
               	   var marker = creerMarker(point, markers[i].getAttribute("info"), markers[i].getAttribute("details"),markers[i].getAttribute("icone"));
                   map.addOverlay(marker);
                 }
               });
             }
           }
     
           //]]>
           </script>
         </head>
     
         <body onload="load()" onunload="GUnload()">
           <div id="map" style="width: 600px; height: 600px"></div>
         </body>
       </html>
    Je rencontre un problème avec la fonction GEvent.addListener.
    J'ai essayé plusieurs solution :
    - Celle-ci.
    - A la place de "coucou" lui mettre une variable.
    - Avec des onglets marker.openInfoWindowTabsHtml
    - Sur divers hébergeurs.
    Mais toujours la même erreurs lors du clic sur un marqueur de ma carte:
    Ligne : 1244
    Caratères : 56
    Erreur 'X' a la valeur Null ou n'est pas un objet
    Code 0
    et l'URL du site


    Si quelqu'un à la moindre idée elle sera la bien venue.

    Merci.

  2. #2
    Membre éclairé Avatar de xess91
    Homme Profil pro
    Inscrit en
    Octobre 2008
    Messages
    408
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Octobre 2008
    Messages : 408
    Par défaut
    voila une fonction qui fonctionne très bien je pense que ça peut t'aider!

    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
     
    			function initialize() 
    				{ 
    				if (GBrowserIsCompatible()) 
    					{ 
    					var map = new GMap2(document.getElementById("map")); 
    					map.setCenter(new GLatLng(48.746871, 2.2673007), 14); 
    					map.addControl(new ExtLargeMapControl()); 
    					var baseIcon = new GIcon();
    					baseIcon.iconSize=new GSize(124,50);
    					baseIcon.shadowSize=new GSize(56,32);
    					baseIcon.iconAnchor=new GPoint(16,32);
    					baseIcon.infoWindowAnchor=new GPoint(16,0);
    					var logo = new GIcon(baseIcon, "logocarte.png", null, "");
    					function createMarker(point, txt, icon, nom)
    						{
    						var marker = new GMarker(point, {icon: icon, title: nom});
    						GEvent.addListener(marker, "click", function()
    							{
    							marker.openInfoWindowHtml(txt);
    							});
    						return marker;
    						}
     
    					var point = new GLatLng(48.746871, 2.2673007); map.addOverlay(createMarker(point,"<img src='logocarte.png' style='width:124px;height:50px;'<strong>CSW </strong><br />Accès A86 A6/A10 N118/N104<br /> à 15 mins de la capitale ","CSW"));         
    					}
    				else
    					{ 
    					alert('Désolé, mais votre navigateur n\'est pas compatible avec Google Maps'); 
    					} 
    				}
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <body onload="initialize()">
    <div id="map">
    </div>
    </body>
    Pardon j'avais oublié il faut changer cette ligne:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    map.addControl(new ExtLargeMapControl());
    par ta ligne ...smallmapcontrol...

  3. #3
    Membre averti
    Inscrit en
    Février 2011
    Messages
    30
    Détails du profil
    Informations forums :
    Inscription : Février 2011
    Messages : 30
    Par défaut
    Bonjour, voilà j'aimerais savoir comment rendre un polygone cliquable. J'ai créé un polygone
    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
     
    var monpolygone = new GPolygon([
                new GLatLng(50.641895204617235, 3.0393075942993164),
                new GLatLng(50.64246672501933, 3.0414533615112305),
                new GLatLng(50.64331038529024, 3.04171085357666),
                new GLatLng(50.64306545322356, 3.042783737182617),
                new GLatLng(50.6443717428266, 3.0442428588867188),
                new GLatLng(50.64314709738765, 3.045787811279297),
                new GLatLng(50.643337599885506, 3.047010898590088),
                new GLatLng(50.64257558526024, 3.0472683906555176),
                new GLatLng(50.642085712190244, 3.0496931076049805),
                new GLatLng(50.640806575098544, 3.0481696128845215),
                new GLatLng(50.64019420991196, 3.0487489700317383),
                new GLatLng(50.63997647814491, 3.0477404594421387),
                new GLatLng(50.63895584704025, 3.047182559967041),
                new GLatLng(50.63868367500226, 3.0457019805908203),
                new GLatLng(50.6380984997833, 3.044736385345459),
                new GLatLng(50.63852037102293, 3.044006824493408),
                new GLatLng(50.63803045568031, 3.0417752265930176),
                new GLatLng(50.63966348696253, 3.041367530822754),
                new GLatLng(50.63999008640991, 3.0403804779052734),
                new GLatLng(50.64057523807698, 3.0408740043640137),
                new GLatLng(50.641895204617235, 3.0393075942993164)
                ], "#990000", 5, 1, "#ff0000", 0.2);	
     
     
    		  // Affichage du polygone
              map.addOverlay(monpolygone);
    Et je voudrais lui ajouter un event qui ouvrirait une autre page, mais je ne sais pas comment faire, pouvez-vous m'aider ?

    Merci.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. utiliser les tag [MFC] [Win32] [.NET] [C++/CLI]
    Par hiko-seijuro dans le forum Visual C++
    Réponses: 8
    Dernier message: 08/06/2005, 16h57
  2. Réponses: 4
    Dernier message: 05/06/2002, 15h35
  3. utilisation du meta type ANY
    Par Anonymous dans le forum CORBA
    Réponses: 1
    Dernier message: 15/04/2002, 13h36
  4. [BCB5] Utilisation des Ressources (.res)
    Par Vince78 dans le forum C++Builder
    Réponses: 2
    Dernier message: 04/04/2002, 17h01
  5. Réponses: 2
    Dernier message: 21/03/2002, 00h01

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