使用Google方向时更改infoWindow [英] Changing the infoWindow when using google directions

查看:93
本文介绍了使用Google方向时更改infoWindow的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用Google语音指示API,它工作正常,并使用以下代码行将8个航路点绘制到我的地图上:

  directionsDisplay.setDirections(response); 

但是,每个标记点击时会显示一个包含航点地址的信息窗口。有没有办法改变这些infowindows的内容?



在此先感谢James。

解决方案

DirectionsRenderer使用{suppressInfoWindows:true}选项,在地图上添加点击侦听器,以在InfoWindow中显示您想要的内容。您可能想要使用{suppressMarkers:true}并创建您自己的标记,以便您可以将点击监听器附加到标记。 自定义标记示例(比您需要的更复杂,但它显示了如何使用infowindows创建自定义标记)



自定义标记和航点的示例


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.

解决方案

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

这篇关于使用Google方向时更改infoWindow的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆