AI-generated Key Takeaways
-
GMSMutablePathis a dynamic array used to represent a series of geographical coordinates (CLLocationCoordinate2D). -
It provides methods to add, insert, replace, and remove coordinates within the path.
-
GMSMutablePathallows for flexible manipulation of paths, enabling resizing and modification of coordinate sequences. -
This class serves as the mutable counterpart to the read-only
GMSPathclass.
GMSMutablePath
@interface GMSMutablePath : GMSPathGMSMutablePath is a dynamic (resizable) array of CLLocationCoordinate2D. All coordinates
must be valid. GMSMutablePath is the mutable counterpart to the immutable GMSPath.
-
Adds
coordat the end of the path.Declaration
Swift
func add(_ coord: CLLocationCoordinate2D)Objective-C
- (void)addCoordinate:(CLLocationCoordinate2D)coord; -
Adds a new CLLocationCoordinate2D instance with the given lat/lng.
Declaration
Swift
func addLatitude(_ latitude: CLLocationDegrees, longitude: CLLocationDegrees)Objective-C
- (void)addLatitude:(CLLocationDegrees)latitude longitude:(CLLocationDegrees)longitude; -
Inserts
coordatindex.If this is smaller than the size of the path, shifts all coordinates forward by one. Otherwise, behaves as
-replaceCoordinateAtIndex:withCoordinate:.Declaration
Swift
func insert(_ coord: CLLocationCoordinate2D, at index: UInt)Objective-C
- (void)insertCoordinate:(CLLocationCoordinate2D)coord atIndex:(NSUInteger)index; -
Replace the coordinate at
indexwithcoord. Ifindexis after the end, grows the array with an undefined coordinate.Declaration
Swift
func replaceCoordinate(at index: UInt, with coord: CLLocationCoordinate2D)Objective-C
- (void)replaceCoordinateAtIndex:(NSUInteger)index withCoordinate:(CLLocationCoordinate2D)coord; -
Remove entry at
index.If
index< count decrements size. Ifindex>= count this is a silent no-op.Declaration
Swift
func removeCoordinate(at index: UInt)Objective-C
- (void)removeCoordinateAtIndex:(NSUInteger)index; -
Removes the last coordinate of the path.
If the array is non-empty decrements size. If the array is empty, this is a silent no-op.
Declaration
Swift
func removeLastCoordinate()Objective-C
- (void)removeLastCoordinate; -
Removes all coordinates in this path.
Declaration
Swift
func removeAllCoordinates()Objective-C
- (void)removeAllCoordinates;