Toggle visibility of polyline using Google API V3

和自甴很熟 提交于 2020-01-06 07:57:07

问题


I know you can toggle visibility of markers using google api, but is it possible to toggle the visibility of a polyline using an html checkbox?

Basically, I have a polyline and if the checkbox is checked, I want the polyline visible, and if it is unchecked, I want it hidden. Is this possible?


回答1:


You toggle the visibility of a polyline the same way you do a marker.

setMap(null)

To display it again, call the setMap method with a reference to your google.maps.Map object.

documentation

setMap(map:Map) - Renders this shape on the specified map. If map is set to null, the shape will be removed.



来源:https://stackoverflow.com/questions/13678041/toggle-visibility-of-polyline-using-google-api-v3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!