views:

2395

answers:

2

I'm attempting to add some text to the directions results the Google Maps API returns to the specified div (directionsPanel). This code below would work fine, except that the jQuery line fires before loadFromWaypoints has finished modifying the DOM. If I run that line by manually triggering it after the directions content has finished loading, it executes as expected.

directions = new GDirections(map, directionsPanel);
directions.loadFromWaypoints(waypoints);

$("td[@jscontent='address']").append(" some content");

How can I add some sort of listener (on perhaps either the loadFromWaypoints callback function or the directionsPanel div itself) to execute my jQuery line after the DOM has finished reloading?

+2  A: 

The documentation is not great, but it talks about a "load" and an "addoverlay" event http://code.google.com/apis/maps/documentation/reference.html#GDirections

GEvent.addListener(directions, "addoverlay", function() {
    $("td[jscontent='address']").append(" some content"); 
});
Lucas Moellers
I was afraid this might fire when the first marker is added or before the div content is drawn, but it seems to work well. I was even able to hide the last marker using this.
Soldarnal
A: 

thank you very much :) A need addoverlay