Pour ceux qui aiment s’amuser avec Google Maps/HTML/JavaScript/Ajax blah…
Je vous recommande la lecture de ce site web : http://www.econym.demon.co.uk/googlemaps/

Bon aujourd’hui ce fut lutte avec l’API de Google Maps et TPhoto. En effet, pour les besoins du job, nous avons besoin d’ajouter une photo sur une map google. Pour ce faire nous utilisons la class TPhoto. Néanmoins, cela marche très bien mais avec beaucoup de GMarker j’avais beaucoup de problème sur le resize de la photo liée au marqueur.
  =>Genre “NULL pointer” 😉
A la vue du code normal :

 function TPhoto(){} TPhoto.prototype.initialize=function(map){ [snip initilization] GEvent.bind(map, "zoomend", this, function(){this.setPosition(map)}); GEvent.bind(map, "moveend", this, function(){this.setPosition(map)}); } TPhoto.prototype.setPosition=function(a) { [blah] } TPhoto.prototype.setOpacity=function(b) { [blah] } GMap2.prototype.addTPhoto=function(a) { a.initialize(this); } GMap2.prototype.removeTPhoto=function(a) { var b = document.getElementById(a.id); this.getPane(G_MAP_MAP_PANE).removeChild(b); delete(b); } 

Lorsque l’on supprime une instance de TPhoto, on ne ‘unbind’ pas les évenements ‘zoomend’ et ‘moveend’ de la map.
La solution faire le ‘unbind’ :

 GMap2.prototype.removeTPhoto=function(a) { var b = document.getElementById(a.id); this.getPane(G_MAP_MAP_PANE).removeChild(b); GEvent.clearNode(this); delete(b); } 

D’où le patch :

 --- tphoto.2.05.js.orig 2007-03-06 18:09:04.000000000 +0100 +++ tphoto.2.05.js 2007-03-06 18:09:29.000000000 +0100 @@ -42,6 +42,7 @@ GMap2.prototype.addTPhoto=function(a){ GMap2.prototype.removeTPhoto=function(a){ var b=document.getElementById(a.id); this.getPane(G_MAP_MAP_PANE).removeChild(b); + GEvent.clearNode(this); delete(b); } 

Téléchargeable

Bref, c’est bon je peux enfin passer à autre chose ! Youpi !!!!

Google maps, TPhoto, patch

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.