joseprupi
joseprupi

Reputation: 349

How to remove GMSPolygon from GMSMapView

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

Upvotes: 11

Views: 6136

Answers (3)

Saxon Druce
Saxon Druce

Reputation: 17624

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

Upvotes: 18

Carlos Correia
Carlos Correia

Reputation: 43

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

Upvotes: 2

Jing
Jing

Reputation: 1965

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.

Upvotes: 6

Related Questions