Bonjour,
je voudrais afficher plusieurs location sur la même carte.
Mes adresses venant d'un tableau php, j'ai tout d'abord converti mon tableau pour pouvoir l'utiliser en javascript.
J'initialise ensuite la carte, et pour chaque données du tableau, je voudrais qu'un nouveau marqueur soit créé.
J'ai fait une alert de mes valeurs de tableau, elles sont toutes bien récupérés.
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 function initialize() { <?php echo "var tab = '".implode("<>", $tableau)."'.split('<>');"; ?> if (GBrowserIsCompatible()) { function createMarker(point,html) { var marker = new GMarker(point); GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml(html); }); return marker;} var map = new GMap2(document.getElementById('map_canvas')); map.setCenter(new GLatLng(<?php echo $coor1 ?>),12); map.addControl(new GSmallMapControl()); map.addControl(new GMapTypeControl()); function place(lat,lng) { var point=new GLatLng(lat, lng); var marker = createMarker(point,'<div class="texte-11"><a href="url de votre lien">Test</a><br><img src="url de votre image" border="0" height="80" width="180"><br>text</div>'); map.addOverlay(new GMarker(point)); } for (var i in tab) { var coo= tab[i]; var mar=place (coo); } } else{ alert('Sorry but your navigator is not compatible with Google Maps'); } } </script>
J'ai aussi essayé plusieurs lignes "var mar=place (coo);" avec des données en dure et tout marche nickel
Le seul problème est dans la boucle, un seul marqueur s'affiche, au pif sur la carte.
Merci pour votre aide, je bloque depuis pas mal de temps et c'est assez pressé :s
Partager