Toggle hide/show Google map markers

前端 未结 2 1851
一向
一向 2021-01-03 14:04

I have a custom Google map with markers of artist locations. I want to make 8 different categories of markers. I read about having to make arrays of markers and assigning a

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-03 14:27

    you can store them in an array and toggle the visbility with marker.setMap(null) for invisible and marker.setMap(map) for visible.

    see the example from the docs: https://developers.google.com/maps/documentation/javascript/examples/marker-remove

提交回复
热议问题