Appel de fonction depuis une table dynamique
Bonjour à tous !!
Je développe une application cartographique Googlemaps combinée à une table. J'affiche dynamiquement des markers sur ma carte ainsi que la table associée. J'ai défini sur chaque marker un évènement onclick qui centre et zoom la carte sur le marker en question. J'aimerais obtenir le même comportement en cliquant sur le nom du marker dans la table. J'y arrive à peu près... disons que j'ai deux solutions : une qui marche sous IE et une qui marche sous Firefox. Il me faudrait une solution qui marche sur les deux ;) La carte est visible ici
L'event :
Code:
1 2 3 4
| google.maps.event.addListener(gb_agglomerations[gb_agglomerations.length-1], "click", function()
{
select_agglo(this.id, this.city, this.x, this.y);
}); |
Appel depuis la table, l'event est défini au niveau de la ligne html_href.onclick ou html_href.setAttribute
Code:
1 2 3 4 5 6 7 8 9 10 11
| for (ville in table_agglo)
{
var html_td2 = document.createElement("td");
var htext2=document.createTextNode(table_agglo[ville]['name']);
// the name of the agglomeration is a link to the map centered on the agglomeration
var html_href = document.createElement("a");
//marche pour IE
//html_href.onclick = function(){return select_agglo(table_agglo[ville]['id'],table_agglo[ville]['name'],table_agglo[ville]['x'],table_agglo[ville]['y'])};
// marche Firefox
html_href.setAttribute('onclick', "select_agglo(table_agglo["+ville+"]['id'],table_agglo["+ville+"]['name'],table_agglo["+ville+"]['x'],table_agglo["+ville+"]['y'])");
html_href.setAttribute('href', '#map_container'); |
Avez-vous des idées? Merci.