AI-generated Key Takeaways
- 
          GMSMapViewis the primary class for displaying and interacting with Google Maps on iOS, handling map operations on the main thread.
- 
          It offers properties for controlling map behavior, including camera position, map type, user location, and various display settings. 
- 
          Developers can initialize GMSMapViewwith default or custom options, utilizing methods to manipulate the camera, manage map content, and access feature layers.
- 
          Camera manipulation methods allow for both instant changes and animated transitions, providing flexibility in controlling the map's viewpoint. 
- 
          GMSMapViewenables access to feature layers for specific feature types or dataset IDs, offering advanced customization options for map rendering.
GMSMapView
@interface GMSMapView : UIViewThis is the main class of the Google Maps SDK for iOS and is the entry point for all methods related to the map.
The map should be instantiated with one of the constructors -init or -initWithOptions:.
GMSMapView can only be read and modified from the main thread, similar to all UIKit objects.
 Calling these methods from another thread will result in an exception or undefined behavior.
- 
                  
                  GMSMapViewdelegate.DeclarationSwift @IBOutlet weak var delegate: (any GMSMapViewDelegate)? { get set }Objective-C @property (nonatomic, weak, nullable) id<GMSMapViewDelegate> delegate;
- 
                  
                  Controls the camera, which defines how the map is oriented. Modification of this property is instantaneous. DeclarationSwift @NSCopying var camera: GMSCameraPosition { get set }Objective-C @property (nonatomic, copy) GMSCameraPosition *_Nonnull camera;
- 
                  
                  Returns a GMSProjectionobject that you can use to convert between screen coordinates and latitude/longitude coordinates.This is a snapshot of the current projection, and will not automatically update when the camera moves. It represents either the projection of the last drawn GMSMapViewframe, or; where the camera has been explicitly set or the map just created, the upcoming frame. It will never be nil.DeclarationSwift var projection: GMSProjection { get }Objective-C @property (nonatomic, readonly) GMSProjection *_Nonnull projection;
- 
                  
                  Controls whether the My Location dot and accuracy circle is enabled. Defaults to NO. DeclarationSwift var isMyLocationEnabled: Bool { get set }Objective-C @property (nonatomic, assign, unsafe_unretained, readwrite, getter=isMyLocationEnabled) BOOL myLocationEnabled;
- 
                  
                  If My Location is enabled, reveals where the device location dot is being drawn. If it is disabled, or it is enabled but no location data is available, this will be nil. This property is observable using KVO. DeclarationSwift var myLocation: CLLocation? { get }Objective-C @property (nonatomic, readonly, nullable) CLLocation *myLocation;
- 
                  
                  The marker that is selected. Setting this property selects a particular marker, showing an info window on it. If this property is non-nil, setting it to nil deselects the marker, hiding the info window. This property is observable using KVO. 
- 
                  
                  Controls whether the map is drawing traffic data, if available. This is subject to the availability of traffic data. Defaults to NO. DeclarationSwift var isTrafficEnabled: Bool { get set }Objective-C @property (nonatomic, assign, unsafe_unretained, readwrite, getter=isTrafficEnabled) BOOL trafficEnabled;
- 
                  
                  Controls the type of map tiles that should be displayed. Defaults to kGMSTypeNormal. DeclarationSwift var mapType: GMSMapViewType { get set }Objective-C @property (nonatomic) GMSMapViewType mapType;
- 
                  
                  Controls the style of the map. A non-nil mapStyle will only apply if mapType is Normal. DeclarationSwift var mapStyle: GMSMapStyle? { get set }Objective-C @property (nonatomic, nullable) GMSMapStyle *mapStyle;
- 
                  
                  DeclarationSwift var overrideUserInterfaceStyle: UIUserInterfaceStyle { get set }Objective-C @property(nonatomic) UIUserInterfaceStyle overrideUserInterfaceStyle
- 
                  
                  Minimum zoom (the farthest the camera may be zoomed out). Defaults to kGMSMinZoomLevel. Modified with -setMinZoom:maxZoom:. DeclarationSwift var minZoom: Float { get }Objective-C @property (nonatomic, readonly) float minZoom;
- 
                  
                  Maximum zoom (the closest the camera may be to the Earth). Defaults to kGMSMaxZoomLevel. Modified with -setMinZoom:maxZoom:. DeclarationSwift var maxZoom: Float { get }Objective-C @property (nonatomic, readonly) float maxZoom;
- 
                  
                  If set, 3D buildings will be shown where available. Defaults to YES. This may be useful when adding a custom tile layer to the map, in order to make it clearer at high zoom levels. Changing this value will cause all tiles to be briefly invalidated. DeclarationSwift var isBuildingsEnabled: Bool { get set }Objective-C @property (nonatomic, assign, unsafe_unretained, readwrite, getter=isBuildingsEnabled) BOOL buildingsEnabled;
- 
                  
                  Sets whether indoor maps are shown, where available. Defaults to YES. If this is set to NO, caches for indoor data may be purged and any floor currently selected by the end-user may be reset. DeclarationSwift var isIndoorEnabled: Bool { get set }Objective-C @property (nonatomic, assign, unsafe_unretained, readwrite, getter=isIndoorEnabled) BOOL indoorEnabled;
- 
                  
                  Gets the GMSIndoorDisplayinstance which allows to observe or control aspects of indoor data display.DeclarationSwift var indoorDisplay: GMSIndoorDisplay { get }Objective-C @property (nonatomic, readonly) GMSIndoorDisplay *_Nonnull indoorDisplay;
- 
                  
                  Gets the GMSUISettingsobject, which controls user interface settings for the map.DeclarationSwift var settings: GMSUISettings { get }Objective-C @property (nonatomic, readonly) GMSUISettings *_Nonnull settings;
- 
                  
                  Controls the ‘visible’ region of the view. By applying padding an area around the edge of the view can be created which will contain map data but will not contain UI controls. If the padding is not balanced, the visual center of the view will move as appropriate. Padding will also affect the projectionproperty so the visible region will not include the padding area.GMSCameraUpdatefitToBounds will ensure that both this padding and any padding requested will be taken into account.This property may be animated within a UIView-based animation block. DeclarationSwift var padding: UIEdgeInsets { get set }Objective-C @property (nonatomic) UIEdgeInsets padding;
- 
                  
                  Controls how safe area insets are added to the padding values. Like padding, safe area insets position map controls such as the compass, my location button and floor picker within the device safe area. Defaults to kGMSMapViewPaddingAdjustmentBehaviorAlways.DeclarationSwift var paddingAdjustmentBehavior: GMSMapViewPaddingAdjustmentBehavior { get set }Objective-C @property (nonatomic) GMSMapViewPaddingAdjustmentBehavior paddingAdjustmentBehavior;
- 
                  
                  Defaults to YES. If set toNO,GMSMapViewwill generate accessibility elements for overlay objects, such asGMSMarkerandGMSPolyline.This property follows the informal UIAccessibilityprotocol, except for the default value ofYES.DeclarationSwift var accessibilityElementsHidden: Bool { get set }Objective-C @property (nonatomic) BOOL accessibilityElementsHidden;
- 
                  
                  Accessor for the custom CALayertype used for the layer.DeclarationSwift var layer: GMSMapLayer { get }Objective-C @property (nonatomic, retain, readonly) GMSMapLayer *_Nonnull layer;
- 
                  
                  Controls the rendering frame rate. Default value is kGMSFrameRateMaximum.DeclarationSwift var preferredFrameRate: GMSFrameRate { get set }Objective-C @property (nonatomic) GMSFrameRate preferredFrameRate;
- 
                  
                  If not nil, constrains the camera target so that gestures cannot cause it to leave the specified bounds. DeclarationSwift var cameraTargetBounds: GMSCoordinateBounds? { get set }Objective-C @property (nonatomic, nullable) GMSCoordinateBounds *cameraTargetBounds;
- 
                  
                  All conditionally-available (dependent on mapID or other map settings) capabilities that are available at the current moment in time. Does not include always-available capabilities. DeclarationSwift var mapCapabilities: GMSMapCapabilityFlags { get }Objective-C @property (nonatomic, readonly) GMSMapCapabilityFlags mapCapabilities;
- 
                  
                  Initializes with CGRectZeroand default options.DeclarationSwift convenience init()Objective-C - (nonnull instancetype)init;
- 
                  
                  Creates a new map view with the given options. The value of the options object is copied by this method. DeclarationSwift init(options: GMSMapViewOptions)Objective-C - (nonnull instancetype)initWithOptions:(nonnull GMSMapViewOptions *)options;
- 
                  
                  Deprecated Use -init or -initWithOptions: instead. DeclarationSwift convenience init(frame: CGRect)Objective-C - (instancetype)initWithFrame:(CGRect)frame __GMS_AVAILABLE_BUT_DEPRECATED_MSG("Use -init or -initWithOptions: instead.");
- 
                  
                  Deprecated Use -init or -initWithOptions: instead. DeclarationSwift convenience init?(coder: NSCoder)Objective-C - (nullable instancetype)initWithCoder:(NSCoder *)coder __GMS_AVAILABLE_BUT_DEPRECATED_MSG("Use -init or -initWithOptions: instead.");
- 
                  
                  Deprecated Use -init or -initWithOptions: instead. Builds and returns a map view with a frame and camera target. DeclarationSwift class func map(withFrame frame: CGRect, camera: GMSCameraPosition) -> SelfObjective-C + (nonnull instancetype)mapWithFrame:(CGRect)frame camera:(nonnull GMSCameraPosition *)camera;
- 
                  
                  Deprecated Use -init or -initWithOptions: instead. Convenience initializer to build and return a map view with a frame, map ID, and camera target. DeclarationObjective-C + (nonnull instancetype)mapWithFrame:(CGRect)frame mapID:(nonnull GMSMapID *)mapID camera:(nonnull GMSCameraPosition *)camera;
- 
                  
                  Deprecated Use -init or -initWithOptions: instead. Builds and returns a map view, with a frame and camera target. DeclarationSwift convenience init(frame: CGRect, camera: GMSCameraPosition)Objective-C - (nonnull instancetype)initWithFrame:(CGRect)frame camera:(nonnull GMSCameraPosition *)camera;
- 
                  
                  Deprecated Use -init or -initWithOptions: instead. Builds and returns a map view with a frame, map ID, and camera target. DeclarationSwift convenience init(frame: CGRect, mapID: GMSMapID, camera: GMSCameraPosition)Objective-C - (nonnull instancetype)initWithFrame:(CGRect)frame mapID:(nonnull GMSMapID *)mapID camera:(nonnull GMSCameraPosition *)camera;
- 
                  
                  Deprecated This method is obsolete and will be removed in a future release. Tells this map to power up its renderer. This is optional and idempotent. DeclarationSwift func startRendering()Objective-C - (void)startRendering;
- 
                  
                  Deprecated This method is obsolete and will be removed in a future release. Tells this map to power down its renderer. This is optional and idempotent. DeclarationSwift func stopRendering()Objective-C - (void)stopRendering;
- 
                  
                  Clears all markup that has been added to the map, including markers, polylines and ground overlays. This will not clear the visible location dot or reset the current mapType. DeclarationSwift func clear()Objective-C - (void)clear;
- 
                  
                  Sets minZoomandmaxZoom. This method expects the minimum to be less than or equal to the maximum, and will throw an exception with nameNSRangeExceptionotherwise.DeclarationSwift func setMinZoom(_ minZoom: Float, maxZoom: Float)Objective-C - (void)setMinZoom:(float)minZoom maxZoom:(float)maxZoom;
- 
                  
                  Build a GMSCameraPositionthat presentsboundswithpadding. The camera will have a zero bearing and tilt (i.e., facing north and looking directly at the Earth). This takes the frame and padding of thisGMSMapViewinto account.If the bounds is invalid this method will return a nil camera. DeclarationSwift func camera(for bounds: GMSCoordinateBounds, insets: UIEdgeInsets) -> GMSCameraPosition?Objective-C - (nullable GMSCameraPosition *)cameraForBounds: (nonnull GMSCoordinateBounds *)bounds insets:(UIEdgeInsets)insets;
- 
                  
                  Changes the camera according to update. The camera change is instantaneous (with no animation).DeclarationSwift func moveCamera(_ update: GMSCameraUpdate)Objective-C - (void)moveCamera:(nonnull GMSCameraUpdate *)update;
- 
                  
                  Check whether the given camera positions would practically cause the camera to be rendered the same, taking into account the level of precision and transformations used internally. DeclarationSwift func areEqual(forRenderingPosition position: GMSCameraPosition, position otherPosition: GMSCameraPosition) -> BoolObjective-C - (BOOL)areEqualForRenderingPosition:(nonnull GMSCameraPosition *)position position:(nonnull GMSCameraPosition *)otherPosition;
- 
                  
                  Returns a feature layer of the specified type. Feature layers must be configured in the Cloud Console. If a layer of the specified type does not exist on this map, or if data-driven styling is not enabled, or if the Metal rendering framework is not used, the resulting layer’s isAvailablewill beNO, and will not respond to any calls.Requires the Metal renderer. Learn how to enable Metal at https://developers.google.com/maps/documentation/ios-sdk/config#use-metal DeclarationSwift func featureLayer(of featureType: FeatureType) -> FeatureLayer<PlaceFeature>Objective-C - (nonnull GMSFeatureLayer<GMSPlaceFeature *> *)featureLayerOfFeatureType: (nonnull GMSFeatureType)featureType;
- 
                  
                  Returns a dataset feature layer of the specified dataset. Dataset IDs must be configured in the Cloud Console. If a dataset of the specified ID does not exist on this map, or if data-driven styling is not enabled, the resulting layer’s isAvailablewill beNO, and will not respond to any calls.DeclarationSwift func datasetFeatureLayer(of datasetID: String) -> DatasetFeatureLayerObjective-C - (nonnull GMSDatasetFeatureLayer *)datasetFeatureLayerOfDatasetID: (nonnull NSString *)datasetID;
- 
                  
                  Animates the camera of this map to cameraPosition.DeclarationSwift func animate(to cameraPosition: GMSCameraPosition)Objective-C - (void)animateToCameraPosition:(nonnull GMSCameraPosition *)cameraPosition;
- 
                  
                  As -animateToCameraPosition:, but changes only the location of the camera (i.e., from the current location tolocation).DeclarationSwift func animate(toLocation location: CLLocationCoordinate2D)Objective-C - (void)animateToLocation:(CLLocationCoordinate2D)location;
- 
                  
                  As -animateToCameraPosition:, but changes only the zoom level of the camera.This value is clamped by [kGMSMinZoomLevel, kGMSMaxZoomLevel]. DeclarationSwift func animate(toZoom zoom: Float)Objective-C - (void)animateToZoom:(float)zoom;
- 
                  
                  As -animateToCameraPosition:, but changes only the bearing of the camera (in degrees). Zero indicates true north.DeclarationSwift func animate(toBearing bearing: CLLocationDirection)Objective-C - (void)animateToBearing:(CLLocationDirection)bearing;
- 
                  
                  As -animateToCameraPosition:, but changes only the viewing angle of the camera (in degrees). This value will be clamped to a minimum of zero (i.e., facing straight down) and between 30 and 45 degrees towards the horizon, depending on the relative closeness to the earth.DeclarationSwift func animate(toViewingAngle viewingAngle: Double)Objective-C - (void)animateToViewingAngle:(double)viewingAngle;
- 
                  
                  Applies cameraUpdateto the current camera, and then uses the result as per-animateToCameraPosition:.DeclarationSwift func animate(with cameraUpdate: GMSCameraUpdate)Objective-C - (void)animateWithCameraUpdate:(nonnull GMSCameraUpdate *)cameraUpdate;