How to remove GMSPolygon from GMSMapView

那年仲夏 提交于 2019-12-22 04:01:24

问题


Does exist any way to remove GMSPolygons from GMSMapView?

It does not seem to exist a property of GMSMapView containing them (as GMSPlolyLines), should I clear the map and render all again?

thanks


回答1:


When you create the GMSPolygon you set its map property to add it to the map. To remove it from the map, set its map property to nil. This means you need to keep your own record of the polygons which you've added to the map, which you want to be able to remove later.

For example mySavedPolygon.map = nil




回答2:


From google maps document

  • clear Clears all markup that has been added to the map, including markers, polylines and ground overlays.

So you just use

[mapView clear];

This should clear the polygons.




回答3:


This has been updated, has I am using the clear function, and was looking for a way to keep the polygons while using this.

I've just confirmed against the Google Maps API Reference.

Clears all markup that has been added to the map, including markers, polylines and ground overlays.

https://developers.google.com/maps/documentation/ios-sdk/reference/interface_g_m_s_map_view.html#a28e6b8aeb7c8dc9025dc001f2a5d2c9b



来源:https://stackoverflow.com/questions/17601408/how-to-remove-gmspolygon-from-gmsmapview

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