What is the difference between “marker.setVisible(false)” and “marker.setMap(null)” in Google Maps v3?

后端 未结 2 403
别那么骄傲
别那么骄傲 2020-12-15 06:01

I want to clear a marker on Google Maps.

What is the difference between marker.setVisible(false) and marker.setMap(null)?

But I don

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-15 06:39

    Another key distinction is that setMap(NULL) releases the resources associated with the marker whereas setVisible(false) just makes the marker invisible, but the resources associated with the marker are still allocated.

    If you're dealing with 100s or 1000s of markers, this can become a significant performance and memory issue.

提交回复
热议问题