I am trying to implement a map/direction based application using Google maps V3 API. So far I have been able to display the map and show directions for two locations selected.
However I am unable to set custom content on the InfoWindow using DirectionsRendererOptions. Given below is what I am using.
var renderer = new google.maps.DirectionsRenderer(
{
infoWindow : new google.maps.InfoWindow(
{
content : "This is a test"
}
)});
It seems the custom InfoWindow is getting set, because when the disableAutoPan property is set on the new InfoWindow, the expected behavior happens. However the content is not set.
Is there a way that I can access the content of the InfoWindow (generated by DirectionsRenderer) and also update it ?
Thanks in advance.
This won't 'update' your InfoWindow, rather it replaces it. So no event listeners and setContent.
In the callback for your directionsService.route
, I simply modifed the content of response.routes[i].legs[j].end_address
and response.routes[i].legs[j].start_address
to HTML I wanted.
I'm not building a really complex application (plus I'm just learning the GMaps API for the first time) so this works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With