Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the infoWindow when using google directions

I am currently using googles directions API, it works fine, and plots 8 waypoints onto my map with the route using this line of code:

    directionsDisplay.setDirections(response);

However, each marks, when clicked, shows up an info window with the address of the waypoint. Is there a way to change the content of these infowindows?

Thanks in advance, James.

like image 440
user2254372 Avatar asked Oct 05 '22 02:10

user2254372


1 Answers

Use the {suppressInfoWindows: true} option to the DirectionsRenderer, add a click listener to the map to display what you want in an InfoWindow. You may want to use {suppressMarkers:true} and create your own Markers so you can attach the click listener to the marker.

Example with custom markers (more complicated than you need, but it shows how to create custom markers with infowindows)

Example with custom markers and a waypoint

like image 195
geocodezip Avatar answered Oct 18 '22 04:10

geocodezip