How to set custom infoWindow of setOptions of google.maps.DirectionsRenderer()?

6,532 views
Skip to first unread message

Dan

unread,
Sep 13, 2011, 6:57:09 PM9/13/11
to google-map...@googlegroups.com
I have multiple waypoints made by using the reference of this example:

Could anyone help me how to customize the infoWindow of the infoWindow of setOptions of google.maps.DirectionsRenderer()?

My DirectionsRenderer variable is this:
var directionsDisplay = new google.maps.DirectionsRenderer();

I have made an infoWindow variable:
var infowindow_forRoutedMarker new google.maps.InfoWindow({
                content: companyName_and_address[i]
              });


Right now, this is how I set my directionsDisplay:

directionsService.route(request, function (result, status) {
                if (status == google.maps.DirectionsStatus.OK) {
                    directionsDisplay.setDirections(result); 
                  
                    directionsDisplay.setOptions({
                        draggable: false,
                        infoWindowinfowindow_forRoutedMarker,
                        suppressInfoWindows: false,
                        suppressMarkers: false,
                        markerOptions: ({ clickable: true,
                                          zIndex: 3 })
                    });
                }
            });


Is it possible to change the default infoWindow to my 
infowindow_forRoutedMarker?

MymsMan

unread,
Sep 14, 2011, 3:31:58 AM9/14/11
to google-map...@googlegroups.com
Are you attempting to have you own information appear at each of the waypoint markers instead of the normal direction renderer text?

If so create your own marker and infowindow for each of the waypoints and end points,  and change your options to be
                    directionsDisplay.setOptions({
                        draggable: false,
                        suppressInfoWindows: false,
                        suppressMarkers: true})



Dan

unread,
Sep 14, 2011, 3:39:16 AM9/14/11
to google-map...@googlegroups.com
i just want the infoWindow to display my own information.
The original directionsDisplay markers are still needed because I still need to see the order alphabetical letters shown on each marker.

xelawho

unread,
Sep 14, 2011, 11:49:21 AM9/14/11
to Google Maps JavaScript API v3
> i just want the infoWindow to display my own information.

it should work. do you have a link to your own map?

xelawho

unread,
Sep 14, 2011, 3:20:22 PM9/14/11
to Google Maps JavaScript API v3
on second thoughts, no it shouldn't - that line should be:
suppressInfoWindows: true,

MymsMan

unread,
Sep 14, 2011, 5:22:19 PM9/14/11
to google-map...@googlegroups.com
The description of the infoWindow option is:
"The InfoWindow in which to render text information when a marker is clicked. Existing info window content will be overwritten and its position moved. If no info window is specified, the DirectionsRenderer will create and use its own info window. This property will be ignored if suppressInfoWindows is set to true"

So you can not provide window text to be displayed when the lettered markers are clicked,  you need to suppress the marker and supply your own markers and windows. I use the google chart icons http://code.google.com/apis/chart/image/docs/gallery/dynamic_icons.html to create lettered/numbered icons.

If you specify  suppressInfoWindows: false you will still be able to click on the individual intermediate directions steps and have the window popup to show the location of the step while if you specify true you would not have access to the intermediate windows.


xelawho

unread,
Sep 14, 2011, 6:23:56 PM9/14/11
to Google Maps JavaScript API v3
> If you specify  suppressInfoWindows: false you will still be able to click
> on the individual intermediate directions steps and have the window popup to
> show the location of the step while if you specify true you would not have
> access to the intermediate windows.

ah, yeah - I forgot about clickability... I guess you could keep track
of waypoints and make those areas clickable for displaying custom
infowindows, kind of mimicking a marker click, but yes - your strategy
of using chart icons sounds way easier.

Dan

unread,
Sep 14, 2011, 6:41:30 PM9/14/11
to Google Maps JavaScript API v3
I figured out an alternative last night.
create another new set up markers, and another new set of infoWindow,
then setup their z-index to control with markers to display at the
highest level.
and for the infoWindow, i will just let it open automatically every
time I opened up my map.

MymsMan

unread,
Sep 15, 2011, 7:31:54 AM9/15/11
to google-map...@googlegroups.com
The simple answer, from your other thread, is just to update the start_address/end_address  text in the DirectionsLeg(s) returned by the directions service
Reply all
Reply to author
Forward
0 new messages