aide pour google map

Toutes vos questions sur Google... le moteur...

Modérateurs: serrum, TOMHTML, kendos, Luka, Knos

aide pour google map

Messagepar y.berges le 11 Jan 2007, 17:29

Salut a tous je galere un peu sur google map
voicic mon code
Code: Tout sélectionner
  <body onunload="GUnload()">
    <!-- the div where the map will be displayed -->
   <center> <div id="map" style="width: 500px; height: 600px"></div></center>
    <script type="text/javascript">
    //<![CDATA[

    // Check to see if this browser can run the Google API
    if (GBrowserIsCompatible()) {

      var gmarkers = [];
      var htmls = [];
      var to_htmls = [];
      var from_htmls = [];
      var i=0;
    
// A function to create the marker and set up the event window
      function createMarker(point,name,html) {
        var marker = new GMarker(point);

        // The info window version with the "to here" form open
        to_htmls[i] = html + '<br>Itin&eacute;raire <b></b> vers ce lieu- <a href="javascript:fromhere(' + i + ')">depuis ce lieu</a>' +
           '<br>Lieu de d&eacute;part: <form action="http://maps.google.com/maps" method="get" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
           '<INPUT value="Itin&eacute;raire" TYPE="SUBMIT">' +
           '<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() +
                  // "(" + name + ")" +
           '"/>';
        // The info window version with the "to here" form open
        from_htmls[i] = html + '<br>Itin&eacute;raire <a href="javascript:tohere(' + i + ')">vers ce lieu</a> - <b>depuis ce lieu</b>' +
           '<br>Lieu arriv&eacute;e:<form action="http://maps.google.com/maps" method="get"" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br>' +
           '<INPUT value="Itin&eacute;raire" TYPE="SUBMIT">' +
           '<input type="hidden" name="saddr" value="' + point.lat() + ',' + point.lng() +
                  // "(" + name + ")" +
           '"/>';
        // The inactive version of the direction info
        html = html + '<br>Itin&eacute;raire: <a href="javascript:tohere('+i+')">vers ce lieu</a> - <a href="javascript:fromhere('+i+')">depuis ce lieu</a>';
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        gmarkers[i] = marker;
        htmls[i] = html;
        i++;
        return marker;
      }
      // functions that open the directions forms
      function tohere(i) {
        gmarkers[i].openInfoWindowHtml(to_htmls[i]);
      }
      function fromhere(i) {
        gmarkers[i].openInfoWindowHtml(from_htmls[i]);
      }
      // Display the map, with some controls and set the initial location
      var map = new GMap2(document.getElementById("map"));
     map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
     map.setCenter(new GLatLng(43.626954,1.447449), 14);
     map.setMapType(G_HYBRID_MAP); // Vue mixte
    map.openInfoWindow(map.getCenter(),document.createTextNode("cliquer sur les marqueurs"));

     // Set up three markers with info windows
      var point = new GLatLng( 43.626954,1.447449);
      var marker = createMarker(point,'bbb',"<div style='font-family:arial;'><b><a href='http://www.lebbb.org'>bbb</a></b><br>96 rue Michel Ange<br>31500 Toulouse<br>tel 0561133714<br>fax 0561133598</div>")
      map.addOverlay(marker);
      var point = new GLatLng( 43.63672,1.441054);
      var marker = createMarker(point,'Renan',"<div style='font-family:arial;'><b>galerie de l'&eacute;cole renan</b><br>che d'Audibert<br>31200 Toulouse</div>")
      map.addOverlay(marker);
      var point = new GLatLng(43.628807,1.444155);
      var marker = createMarker(point,'friche',"<div style='font-family:arial;'><b>La future friche Renan</b><br>14 rue Ernest-Renan 31200<br> Toulouse</div>")
      map.addOverlay(marker);

    }
// display a warning if the browser was not compatible
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
</script>

voila j'ai trois markeur et je voufrais qu'ils aient tous un icon spécial ... j'y arrive pas (j'arrive a avoir un icone diff mais pour tous)
comment faire

Pareil je veux créer une ligne entre c'est 3 points mais cela fait planter l'affichage qqun pour m'aider SVP
Merci
y.berges
Nouveau Zorgler
Nouveau Zorgler
 
Messages: 2
Inscrit le: 11 Jan 2007, 17:27

Messagepar Luka le 11 Jan 2007, 20:12

Pour les couleurs de marqueurs : un exemple sera plus simple que des mots :

Code: Tout sélectionner
var rouge = new GIcon(base);
   rouge.image = http://labs.google.com/ridefinder/images/mm_20_red.png";
   var vert = new GIcon(base);
   vert.image = "http://labs.google.com/ridefinder/images/mm_20_green.png";
   var jaune = new GIcon(base);
   jaune.image = "http://labs.google.com/ridefinder/images/mm_20_yellow.png";

function creer(lon,lat,nom,desc,couleur) {
  var point = new GPoint(lat,lon)
  var marker = new GMarker(point,couleur);
  var html = "<h3>" + nom + "</h3>" + desc;
  GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(html); });
  return marker;
}

var m1 = creer(48.8963,2.2522,"Paris","Ville des lumières","test", rouge); map.addOverlay(m1);
Save energy, Save the world...
Luka
Administrateur
Administrateur
 
Messages: 561
Inscrit le: 07 Juin 2005, 17:10
Localisation: Sherbrooke, Canada

Messagepar y.berges le 13 Jan 2007, 14:03

donc ds mon cas
Code: Tout sélectionner
<body onunload="GUnload()">
    <!-- the div where the map will be displayed -->
   <center> <div id="map" style="width: 500px; height: 600px"></div></center>
    <script type="text/javascript">
    //<![CDATA[

    // Check to see if this browser can run the Google API
    if (GBrowserIsCompatible()) {

      var gmarkers = [];
      var htmls = [];
      var to_htmls = [];
      var from_htmls = [];
      var i=0;
var rouge = new GIcon(base);
   rouge.image = http://labs.google.com/ridefinder/images/mm_20_red.png";
   var vert = new GIcon(base);
   vert.image = "http://labs.google.com/ridefinder/images/mm_20_green.png";
   var jaune = new GIcon(base);
   jaune.image = "http://labs.google.com/ridefinder/images/mm_20_yellow.png";
   
// A function to create the marker and set up the event window
      function createMarker(point,name,html,couleur) {
        var marker = new GMarker(point,couleur);

        // The info window version with the "to here" form open
        to_htmls[i] = html + '<br>Itin&eacute;raire <b></b> vers ce lieu- <a href="javascript:fromhere(' + i + ')">depuis ce lieu</a>' +
           '<br>Lieu de d&eacute;part: <form action="http://maps.google.com/maps" method="get" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="saddr" id="saddr" value="" /><br>' +
           '<INPUT value="Itin&eacute;raire" TYPE="SUBMIT">' +
           '<input type="hidden" name="daddr" value="' + point.lat() + ',' + point.lng() +
                  // "(" + name + ")" +
           '"/>';
        // The info window version with the "to here" form open
        from_htmls[i] = html + '<br>Itin&eacute;raire <a href="javascript:tohere(' + i + ')">vers ce lieu</a> - <b>depuis ce lieu</b>' +
           '<br>Lieu arriv&eacute;e:<form action="http://maps.google.com/maps" method="get"" target="_blank">' +
           '<input type="text" SIZE=40 MAXLENGTH=40 name="daddr" id="daddr" value="" /><br>' +
           '<INPUT value="Itin&eacute;raire" TYPE="SUBMIT">' +
           '<input type="hidden" name="saddr" value="' + point.lat() + ',' + point.lng() +
                  // "(" + name + ")" +
           '"/>';
        // The inactive version of the direction info
        html = html + '<br>Itin&eacute;raire: <a href="javascript:tohere('+i+')">vers ce lieu</a> - <a href="javascript:fromhere('+i+')">depuis ce lieu</a>';
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        gmarkers[i] = marker;
        htmls[i] = html;
        i++;
        return marker;
      }
      // functions that open the directions forms
      function tohere(i) {
        gmarkers[i].openInfoWindowHtml(to_htmls[i]);
      }
      function fromhere(i) {
        gmarkers[i].openInfoWindowHtml(from_htmls[i]);
      }
      // Display the map, with some controls and set the initial location
      var map = new GMap2(document.getElementById("map"));
     map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
     map.setCenter(new GLatLng(43.626954,1.447449), 14);
     map.setMapType(G_HYBRID_MAP); // Vue mixte
    map.openInfoWindow(map.getCenter(),document.createTextNode("cliquer sur les marqueurs"));

     // Set up three markers with info windows
      var point = new GLatLng( 43.626954,1.447449);
      var marker = createMarker(point,'bbb',"<div style='font-family:arial;'><b><a href='http://www.lebbb.org'>bbb</a></b><br>96 rue Michel Ange<br>31500 Toulouse<br>tel 0561133714<br>fax 0561133598</div>",rouge)
      map.addOverlay(marker);
      var point = new GLatLng( 43.63672,1.441054);
      var marker = createMarker(point,'Renan',"<div style='font-family:arial;'><b>galerie de l'&eacute;cole renan</b><br>che d'Audibert<br>31200 Toulouse</div>",jaune)
      map.addOverlay(marker);
      var point = new GLatLng(43.628807,1.444155);
      var marker = createMarker(point,'friche',"<div style='font-family:arial;'><b>La future friche Renan</b><br>14 rue Ernest-Renan 31200<br> Toulouse</div>",vert)
      map.addOverlay(marker);

    }
// display a warning if the browser was not compatible
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
</script>


c'est ca ?
Merci de ton aide
y.berges
Nouveau Zorgler
Nouveau Zorgler
 
Messages: 2
Inscrit le: 11 Jan 2007, 17:27


Retourner vers Zorgloob

Qui est en ligne

Utilisateurs parcourant ce forum : Yahoo [Bot] et 2 invités