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 :

Google Maps


Sujet :

APIs Google

  1. #1
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Avril 2009
    Messages
    1
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2009
    Messages : 1
    Points : 1
    Points
    1
    Par défaut Google Maps
    Bonjour,



    J'ai un petit problème, je suis en train de créer un map affichant des observations météo. Tout fonctionne bien, les markers personnalisée s'affiche, etc...

    Mais quand je fais une recherche, exemple, paris, aucun markers s'affiche. ( Alors qu'ils étaient bien présent avant la recherche sur cette ville.)



    Voici le code javascript et le lien avec la demo.



    http://electro-cult.com/map/map.php



    Merci



    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
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
     //<![CDATA[
     
     
     
        var iconSoleil = new GIcon(); 
        iconSoleil.image = 'http://france.meteofrance.com/meteo/pictos/web/CARTE/40/0_a.gif';
        iconSoleil.shadow = '';
        iconSoleil.iconSize = new GSize(33, 33);
        iconSoleil.shadowSize = new GSize(22, 20);
        iconSoleil.iconAnchor = new GPoint(6, 20);
        iconSoleil.infoWindowAnchor = new GPoint(5, 1);
     
        var iconCouvert = new GIcon(); 
        iconCouvert.image = 'http://france.meteofrance.com/meteo/pictos/web/CARTE/40/0_g.gif';
        iconCouvert.shadow = '';
        iconCouvert.iconSize = new GSize(33, 33);
        iconCouvert.shadowSize = new GSize(22, 20);
        iconCouvert.iconAnchor = new GPoint(6, 20);
        iconCouvert.infoWindowAnchor = new GPoint(5, 1);
     
     
        var iconPluie = new GIcon(); 
        iconPluie.image = 'http://france.meteofrance.com/meteo/pictos/web/CARTE/40/10_c.gif';
        iconPluie.shadow = '';
        iconPluie.iconSize = new GSize(33, 33);
        iconPluie.shadowSize = new GSize(22, 20);
        iconPluie.iconAnchor = new GPoint(6, 20);
        iconPluie.infoWindowAnchor = new GPoint(5, 1);
     
     
     
        var iconNeige = new GIcon(); 
        iconNeige.image = 'http://france.meteofrance.com/meteo/pictos/web/CARTE/40/0_e.gif';
        iconNeige.shadow = '';
        iconNeige.iconSize = new GSize(33, 33);
        iconNeige.shadowSize = new GSize(22, 20);
        iconNeige.iconAnchor = new GPoint(6, 20);
        iconNeige.infoWindowAnchor = new GPoint(5, 1);
     
        var customIcons = [];
        customIcons["Soleil"] = iconSoleil;
        customIcons["Couvert"] = iconCouvert;
    	customIcons["Pluie"] = iconPluie;
        customIcons["Neige"] = iconNeige;
     
     
     
     
     
     
     
       function load() {
     
    if (GBrowserIsCompatible()) {
     
     
    var map = new GMap2(document.getElementById("map"));
            map.addControl(new GSmallMapControl());
            map.addControl(new GMapTypeControl());
     
            var center = new GLatLng(47.35909, 3.38521);
            map.setCenter(center, 6);
            geocoder = new GClientGeocoder();
            var marker = new GMarker(center, {draggable: true});  
            map.addOverlay(marker);
    GEvent.addListener(marker, "dragend", function() {
           var point = marker.getPoint();
    	      map.panTo(point);
           document.getElementById("lat").innerHTML = point.lat().toFixed(7);
           document.getElementById("lng").innerHTML = point.lng().toFixed(7);
     
     
            });
     
     
     
    	 GEvent.addListener(marker, "dragend", function() {
          var point =marker.getPoint();
    	     map.panTo(point);
          document.getElementById("lat").innerHTML = point.lat().toFixed(7);
    	     document.getElementById("lng").innerHTML = point.lng().toFixed(7);
     
            });
     
     
     
            GDownloadUrl("phpsqlajax_genxml.php", 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 address = markers[i].getAttribute("address");
                var type = markers[i].getAttribute("type");
                var point = new GLatLng(parseFloat(markers[i].getAttribute("lat")),
                                        parseFloat(markers[i].getAttribute("lng")));
                var marker = createMarker(point, name, address, type);
                map.addOverlay(marker);
     
              }
            });
          }
        }
     
     
        function createMarker(point, name, address, type) {
          var marker = new GMarker(point, customIcons[type]);	  
          var html = "<b>" + name + "</b> <br/>" + address;
          GEvent.addListener(marker, 'click', function() {
     
            marker.openInfoWindowHtml(html);
          });
          return marker;
        }
     
    function showAddress(address) {
    	   var map = new GMap2(document.getElementById("map"));
           map.addControl(new GSmallMapControl());
           map.addControl(new GMapTypeControl());
           if (geocoder) {
            geocoder.getLatLng(
              address,
              function(point) {
                if (!point) {
                  alert(address + " not found");
                } else {
    		  document.getElementById("lat").innerHTML = point.lat().toFixed(7);
    	   document.getElementById("lng").innerHTML = point.lng().toFixed(7);
    		 map.clearOverlays()
    			map.setCenter(point, 6);
       var marker = new GMarker(point, {draggable: true});  
    		 map.addOverlay(marker);
     
    		GEvent.addListener(marker, "dragend", function() {
          var pt = marker.getPoint();
    	     map.panTo(pt);
          document.getElementById("lat").innerHTML = pt.lat().toFixed(7);
    	     document.getElementById("lng").innerHTML = pt.lng().toFixed(7);
            });
     
     
                }
              }
            );
          }
        }
     
        //]]>
      </script>

  2. #2
    Membre habitué Avatar de scorpking
    Profil pro
    Inscrit en
    Avril 2006
    Messages
    232
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : France

    Informations forums :
    Inscription : Avril 2006
    Messages : 232
    Points : 181
    Points
    181
    Par défaut
    si ta recherche d'adresse est showAdresse si je comprend ton code
    tu refais entièrement ta map à chaque recherche

    met ton objet map dans un espace de nom et appel toujours le même au lieu de recréer ta carte lors de ta recherche fais simplement un zoom ton code sera plus léger

    de plus ton lien est une jolie 404

Discussions similaires

  1. [Google Maps] IE6 refuse d'ouvrir ma page
    Par Shyboy dans le forum APIs Google
    Réponses: 5
    Dernier message: 03/10/2006, 08h47
  2. [Google Maps] Intégrer de nouvelles icônes
    Par Shyboy dans le forum APIs Google
    Réponses: 7
    Dernier message: 01/10/2006, 00h30
  3. [SimpleXML] Google Maps, Problème d'encoding dans une boucle
    Par yahn dans le forum Bibliothèques et frameworks
    Réponses: 1
    Dernier message: 23/09/2006, 19h40
  4. [google maps] probleme avec ie
    Par kowabounga dans le forum Général Python
    Réponses: 1
    Dernier message: 14/09/2006, 15h20
  5. 4D & Google Maps
    Par gbardy dans le forum 4D
    Réponses: 1
    Dernier message: 30/06/2006, 07h32

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