GoogleMaps Framework Reference
Stay organized with collections
Save and categorize content based on your preferences.
GMSMutablePath
@interface GMSMutablePath : GMSPath
GMSMutablePath
is a dynamic (resizable) array of CLLocationCoordinate2D
. All coordinates
must be valid. GMSMutablePath
is the mutable counterpart to the immutable GMSPath
.
-
Adds coord
at 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;
-
Declaration
Swift
func insert(_ coord: CLLocationCoordinate2D, at index: UInt)
Objective-C
- (void)insertCoordinate:(CLLocationCoordinate2D)coord
atIndex:(NSUInteger)index;
-
Replace the coordinate at index
with coord
. If index
is 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. If index
>= 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;
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-27 UTC.
[null,null,["Last updated 2025-08-27 UTC."],[[["\u003cp\u003e\u003ccode\u003eGMSMutablePath\u003c/code\u003e is a dynamic array used to represent a series of geographical coordinates (\u003ccode\u003eCLLocationCoordinate2D\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods to add, insert, replace, and remove coordinates within the path.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eGMSMutablePath\u003c/code\u003e allows for flexible manipulation of paths, enabling resizing and modification of coordinate sequences.\u003c/p\u003e\n"],["\u003cp\u003eThis class serves as the mutable counterpart to the read-only \u003ccode\u003eGMSPath\u003c/code\u003e class.\u003c/p\u003e\n"]]],["`GMSMutablePath` is a resizable array for `CLLocationCoordinate2D` data. You can add coordinates to the end of the path using `addCoordinate:` or `addLatitude:longitude:`. `insertCoordinate:atIndex:` inserts a coordinate at a specific index. `replaceCoordinateAtIndex:withCoordinate:` updates an existing coordinate. Coordinates can be removed via `removeCoordinateAtIndex:`, `removeLastCoordinate`, or `removeAllCoordinates`.\n"],null,["# GoogleMaps Framework Reference\n\nGMSMutablePath\n==============\n\n @interface GMSMutablePath : ../Classes/GMSPath.html\n\n`GMSMutablePath` is a dynamic (resizable) array of `CLLocationCoordinate2D`. All coordinates\nmust be valid. `GMSMutablePath` is the mutable counterpart to the immutable [GMSPath](../Classes/GMSPath.html).\n- `\n ``\n ``\n `\n\n ### [-addCoordinate:](#/c:objc(cs)GMSMutablePath(im)addCoordinate:)\n\n `\n ` \n Adds `coord` at the end of the path. \n\n #### Declaration\n\n Swift \n\n func add(_ coord: CLLocationCoordinate2D)\n\n Objective-C \n\n - (void)addCoordinate:(CLLocationCoordinate2D)coord;\n\n- `\n ``\n ``\n `\n\n ### [-addLatitude:longitude:](#/c:objc(cs)GMSMutablePath(im)addLatitude:longitude:)\n\n `\n ` \n Adds a new CLLocationCoordinate2D instance with the given lat/lng. \n\n #### Declaration\n\n Swift \n\n func addLatitude(_ latitude: CLLocationDegrees, longitude: CLLocationDegrees)\n\n Objective-C \n\n - (void)addLatitude:(CLLocationDegrees)latitude\n longitude:(CLLocationDegrees)longitude;\n\n- `\n ``\n ``\n `\n\n ### [-insertCoordinate:atIndex:](#/c:objc(cs)GMSMutablePath(im)insertCoordinate:atIndex:)\n\n `\n ` \n Inserts `coord` at `index`.\n\n If this is smaller than the size of the path, shifts all coordinates forward by one. Otherwise,\n behaves as [-replaceCoordinateAtIndex:withCoordinate:](../Classes/GMSMutablePath.html#/c:objc(cs)GMSMutablePath(im)replaceCoordinateAtIndex:withCoordinate:). \n\n #### Declaration\n\n Swift \n\n func insert(_ coord: CLLocationCoordinate2D, at index: UInt)\n\n Objective-C \n\n - (void)insertCoordinate:(CLLocationCoordinate2D)coord\n atIndex:(NSUInteger)index;\n\n- `\n ``\n ``\n `\n\n ### [-replaceCoordinateAtIndex:withCoordinate:](#/c:objc(cs)GMSMutablePath(im)replaceCoordinateAtIndex:withCoordinate:)\n\n `\n ` \n Replace the coordinate at `index` with `coord`. If `index` is after the end, grows the array with\n an undefined coordinate. \n\n #### Declaration\n\n Swift \n\n func replaceCoordinate(at index: UInt, with coord: CLLocationCoordinate2D)\n\n Objective-C \n\n - (void)replaceCoordinateAtIndex:(NSUInteger)index\n withCoordinate:(CLLocationCoordinate2D)coord;\n\n- `\n ``\n ``\n `\n\n ### [-removeCoordinateAtIndex:](#/c:objc(cs)GMSMutablePath(im)removeCoordinateAtIndex:)\n\n `\n ` \n Remove entry at `index`.\n\n If `index` \\\u003c count decrements size. If `index` \\\u003e= count this is a silent no-op. \n\n #### Declaration\n\n Swift \n\n func removeCoordinate(at index: UInt)\n\n Objective-C \n\n - (void)removeCoordinateAtIndex:(NSUInteger)index;\n\n- `\n ``\n ``\n `\n\n ### [-removeLastCoordinate](#/c:objc(cs)GMSMutablePath(im)removeLastCoordinate)\n\n `\n ` \n Removes the last coordinate of the path.\n\n If the array is non-empty decrements size. If the array is empty, this is a silent no-op. \n\n #### Declaration\n\n Swift \n\n func removeLastCoordinate()\n\n Objective-C \n\n - (void)removeLastCoordinate;\n\n- `\n ``\n ``\n `\n\n ### [-removeAllCoordinates](#/c:objc(cs)GMSMutablePath(im)removeAllCoordinates)\n\n `\n ` \n Removes all coordinates in this path. \n\n #### Declaration\n\n Swift \n\n func removeAllCoordinates()\n\n Objective-C \n\n - (void)removeAllCoordinates;"]]