GoogleMaps Framework Reference

GMSMapView

  @interface 
 GMSMapView 
 : 
 UIView 
 

This 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.

  • GMSMapView delegate.

    Declaration

    Swift

      @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.

    Declaration

    Swift

      @NSCopying 
     var 
     camera 
     : 
      GMSCameraPosition 
     
     { 
     get 
     set 
     } 
     
    

    Objective-C

      @property 
     ( 
     nonatomic 
     , 
     copy 
     ) 
      GMSCameraPosition 
     
     * 
     _Nonnull 
     camera 
     ; 
     
    
  • Returns a GMSProjection object 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 GMSMapView frame, or; where the camera has been explicitly set or the map just created, the upcoming frame. It will never be nil.

    Declaration

    Swift

      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.

    Declaration

    Swift

      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.

    Declaration

    Swift

      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.

    Declaration

    Swift

      var 
     selectedMarker 
     : 
      GMSMarker 
     
     ? 
     { 
     get 
     set 
     } 
     
    

    Objective-C

      @property 
     ( 
     nonatomic 
     , 
     nullable 
     ) 
      GMSMarker 
     
     * 
     selectedMarker 
     ; 
     
    
  • Controls whether the map is drawing traffic data, if available. This is subject to the availability of traffic data. Defaults to NO.

    Declaration

    Swift

      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.

    Declaration

    Swift

      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.

    Declaration

    Swift

      var 
     mapStyle 
     : 
      GMSMapStyle 
     
     ? 
     { 
     get 
     set 
     } 
     
    

    Objective-C

      @property 
     ( 
     nonatomic 
     , 
     nullable 
     ) 
      GMSMapStyle 
     
     * 
     mapStyle 
     ; 
     
    
  • Declaration

    Swift

      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:.

    Declaration

    Swift

      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:.

    Declaration

    Swift

      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.

    Declaration

    Swift

      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.

    Declaration

    Swift

      var 
     isIndoorEnabled 
     : 
     Bool 
     { 
     get 
     set 
     } 
     
    

    Objective-C

      @property 
     ( 
     nonatomic 
     , 
     assign 
     , 
     unsafe_unretained 
     , 
     readwrite 
     , 
     getter 
     = 
     isIndoorEnabled 
     ) 
     BOOL 
     indoorEnabled 
     ; 
     
    
  • Gets the GMSIndoorDisplay instance which allows to observe or control aspects of indoor data display.

    Declaration

    Swift

      var 
     indoorDisplay 
     : 
      GMSIndoorDisplay 
     
     { 
     get 
     } 
     
    

    Objective-C

      @property 
     ( 
     nonatomic 
     , 
     readonly 
     ) 
      GMSIndoorDisplay 
     
     * 
     _Nonnull 
     indoorDisplay 
     ; 
     
    
  • Gets the GMSUISettings object, which controls user interface settings for the map.

    Declaration

    Swift

      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 projection property so the visible region will not include the padding area. GMSCameraUpdate fitToBounds 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.

    Declaration

    Swift

      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 .

    Declaration

    Swift

      var 
     paddingAdjustmentBehavior 
     : 
      GMSMapViewPaddingAdjustmentBehavior 
     
     { 
     get 
     set 
     } 
     
    

    Objective-C

      @property 
     ( 
     nonatomic 
     ) 
      GMSMapViewPaddingAdjustmentBehavior 
     
     paddingAdjustmentBehavior 
     ; 
     
    
  • Defaults to YES . If set to NO , GMSMapView will generate accessibility elements for overlay objects, such as GMSMarker and GMSPolyline .

    This property follows the informal UIAccessibility protocol, except for the default value of YES .

    Declaration

    Swift

      var 
     accessibilityElementsHidden 
     : 
     Bool 
     { 
     get 
     set 
     } 
     
    

    Objective-C

      @property 
     ( 
     nonatomic 
     ) 
     BOOL 
     accessibilityElementsHidden 
     ; 
     
    
  • Accessor for the custom CALayer type used for the layer.

    Declaration

    Swift

      var 
     layer 
     : 
      GMSMapLayer 
     
     { 
     get 
     } 
     
    

    Objective-C

      @property 
     ( 
     nonatomic 
     , 
     retain 
     , 
     readonly 
     ) 
      GMSMapLayer 
     
     * 
     _Nonnull 
     layer 
     ; 
     
    
  • Controls the rendering frame rate. Default value is kGMSFrameRateMaximum .

    Declaration

    Swift

      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.

    Declaration

    Swift

      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.

    Declaration

    Swift

      var 
     mapCapabilities 
     : 
      GMSMapCapabilityFlags 
     
     { 
     get 
     } 
     
    

    Objective-C

      @property 
     ( 
     nonatomic 
     , 
     readonly 
     ) 
      GMSMapCapabilityFlags 
     
     mapCapabilities 
     ; 
     
    
  • Initializes with CGRectZero and default options.

    Declaration

    Swift

      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.

    Declaration

    Swift

      init 
     ( 
     options 
     : 
      GMSMapViewOptions 
     
     ) 
     
    

    Objective-C

      - 
     ( 
     nonnull 
     instancetype 
     ) 
     initWithOptions 
     :( 
     nonnull 
      GMSMapViewOptions 
     
     * 
     ) 
     options 
     ; 
     
    
  • Deprecated

    Use -init or -initWithOptions: instead.

    Declaration

    Swift

      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.

    Declaration

    Swift

      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.

    Declaration

    Swift

      class 
     func 
     map 
     ( 
     withFrame 
     frame 
     : 
     CGRect 
     , 
     camera 
     : 
      GMSCameraPosition 
     
     ) 
     -> 
     Self 
     
    

    Objective-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.

    Declaration

    Objective-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.

    Declaration

    Swift

      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.

    Declaration

    Swift

      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.

    Declaration

    Swift

      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.

    Declaration

    Swift

      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.

    Declaration

    Swift

      func 
     clear 
     () 
     
    

    Objective-C

      - 
     ( 
     void 
     ) 
     clear 
     ; 
     
    
  • Sets minZoom and maxZoom . This method expects the minimum to be less than or equal to the maximum, and will throw an exception with name NSRangeException otherwise.

    Declaration

    Swift

      func 
     setMinZoom 
     ( 
     _ 
     minZoom 
     : 
     Float 
     , 
     maxZoom 
     : 
     Float 
     ) 
     
    

    Objective-C

      - 
     ( 
     void 
     ) 
     setMinZoom 
     :( 
     float 
     ) 
     minZoom 
     maxZoom 
     :( 
     float 
     ) 
     maxZoom 
     ; 
     
    
  • Build a GMSCameraPosition that presents bounds with padding . 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 this GMSMapView into account.

    If the bounds is invalid this method will return a nil camera.

    Declaration

    Swift

      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).

    Declaration

    Swift

      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.

    Declaration

    Swift

      func 
     areEqual 
     ( 
     forRenderingPosition 
     position 
     : 
      GMSCameraPosition 
     
     , 
     position 
     otherPosition 
     : 
      GMSCameraPosition 
     
     ) 
     -> 
     Bool 
     
    

    Objective-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 isAvailable will be NO , 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

    Declaration

    Swift

      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 isAvailable will be NO , and will not respond to any calls.

    Declaration

    Swift

      func 
     datasetFeatureLayer 
     ( 
     of 
     datasetID 
     : 
     String 
     ) 
     -> 
     DatasetFeatureLayer 
     
    

    Objective-C

      - 
     ( 
     nonnull 
      GMSDatasetFeatureLayer 
     
     * 
     ) 
     datasetFeatureLayerOfDatasetID 
     : 
     ( 
     nonnull 
     NSString 
     * 
     ) 
     datasetID 
     ; 
     
    
  • Animates the camera of this map to cameraPosition .

    Declaration

    Swift

      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 to location ).

    Declaration

    Swift

      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].

    Declaration

    Swift

      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.

    Declaration

    Swift

      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.

    Declaration

    Swift

      func 
     animate 
     ( 
     toViewingAngle 
     viewingAngle 
     : 
     Double 
     ) 
     
    

    Objective-C

      - 
     ( 
     void 
     ) 
     animateToViewingAngle 
     :( 
     double 
     ) 
     viewingAngle 
     ; 
     
    
  • Applies cameraUpdate to the current camera, and then uses the result as per -animateToCameraPosition: .

    Declaration

    Swift

      func 
     animate 
     ( 
     with 
     cameraUpdate 
     : 
      GMSCameraUpdate 
     
     ) 
     
    

    Objective-C

      - 
     ( 
     void 
     ) 
     animateWithCameraUpdate 
     :( 
     nonnull 
      GMSCameraUpdate 
     
     * 
     ) 
     cameraUpdate 
     ; 
     
    
Create a Mobile Website
View Site in Mobile | Classic
Share by: