I updated my app to use version 1.6 of Google Maps API for iOS. It now shows me that three important methods of GMSMapView
are deprecated:
'markers' is deprecated
'polylines' is deprecated
'groundOverlays' is deprecated
At first I thought it might be a problem on my side because there is no mention of this in Google's documentation, but then I saw the header file and noticed that they are in fact deprecated but they do not specify an alternate method to use in order to achieve the same thing:
- (NSArray *)markers __GMS_AVAILABLE_BUT_DEPRECATED;
- (NSArray *)groundOverlays __GMS_AVAILABLE_BUT_DEPRECATED;
- (NSArray *)polylines __GMS_AVAILABLE_BUT_DEPRECATED;
Can somebody point me to how to do this without using deprecated methods? Thanks!
EDIT: I just found a method where you can do [mapView clear]
which would remove all markers and polylines from the map, is there any way to only remove all polylines without removing markers?
Super weird that they didn't mention it in the docs. In the source code, they mention they will be taking it out in a future release:
NOTE: In 1.2 of the Google Maps SDK for iOS, these methods are deprecated. They may not appear in later releases of the SDK. Instead of using these methods, we suggest that you maintain your own references to overlays that you have added to a GMSMapView.
Seems like they're moving the onus onto us as developers to keep references to added overlays. I do that in my app by creating a NSMutableArray
of addedMarkers. Every time I add a marker to the map, it's added to the array.
I assume you could do the same with polylines and ground overlays. Each of those are their own class so it shouldn't be hard to group them and identify them later if you need to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With