Google Maps SDK for iOS

GMSMapView Class Reference


Overview

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 via the convenience constructor [GMSMapView mapWithFrame:camera:]. It may also be created with the default [[GMSMapView alloc] initWithFrame:] method (wherein its camera will be set to a default location).

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.

Public Member Functions

(void) - startRendering
 Tells this map to power up its renderer.
(void) - stopRendering
 Tells this map to power down its renderer.
(void) - clear
 Clears all markup that has been added to the map, including markers, polylines and ground overlays.
(void) - setMinZoom:maxZoom:
 Sets minZoom and maxZoom.
(GMSCameraPosition *) - cameraForBounds:insets:
 Build a GMSCameraPosition that presents bounds with padding.
(void) - moveCamera:
 Changes the camera according to update.
(void) - animateToCameraPosition:
 Animates the camera of this map to cameraPosition.
(void) - animateToLocation:
 As animateToCameraPosition:, but changes only the location of the camera (i.e., from the current location to location).
(void) - animateToZoom:
 As animateToCameraPosition:, but changes only the zoom level of the camera.
(void) - animateToBearing:
 As animateToCameraPosition:, but changes only the bearing of the camera (in degrees).
(void) - animateToViewingAngle:
 As animateToCameraPosition:, but changes only the viewing angle of the camera (in degrees).
(void) - animateWithCameraUpdate:
 Applies cameraUpdate to the current camera, and then uses the result as per animateToCameraPosition:.

Static Public Member Functions

(instancetype) + mapWithFrame:camera:
 Builds and returns a GMSMapView, with a frame and camera target.

Properties

id< GMSMapViewDelegatedelegate
 GMSMapView delegate.
GMSCameraPositioncamera
 Controls the camera, which defines how the map is oriented.
GMSProjectionprojection
 Returns a GMSProjection object that you can use to convert between screen coordinates and latitude/longitude coordinates.
BOOL myLocationEnabled
 Controls whether the My Location dot and accuracy circle is enabled.
CLLocation * myLocation
 If My Location is enabled, reveals where the user location dot is being drawn.
GMSMarkerselectedMarker
 The marker that is selected.
BOOL trafficEnabled
 Controls whether the map is drawing traffic data, if available.
GMSMapViewType mapType
 Controls the type of map tiles that should be displayed.
float minZoom
 Minimum zoom (the farthest the camera may be zoomed out).
float maxZoom
 Maximum zoom (the closest the camera may be to the Earth).
BOOL buildingsEnabled
 If set, 3D buildings will be shown where available.
BOOL indoorEnabled
 Sets whether indoor maps are shown, where available.
GMSIndoorDisplayindoorDisplay
 Gets the GMSIndoorDisplay instance which allows to observe or control aspects of indoor data display.
GMSUISettingssettings
 Gets the GMSUISettings object, which controls user interface settings for the map.
UIEdgeInsets padding
 Controls the 'visible' region of the view.
BOOL accessibilityElementsHidden
 Defaults to YES.
GMSMapLayerlayer
 Accessor for the custom CALayer type used for the layer.

Member Function Documentation

+ (instancetype) mapWithFrame: (CGRect)  frame
camera: (GMSCameraPosition *)  camera 

Builds and returns a GMSMapView, with a frame and camera target.

- (void) startRendering

Tells this map to power up its renderer.

This is optional and idempotent.

- (void) stopRendering

Tells this map to power down its renderer.

This is optional and idempotent.

- (void) clear

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.

- (void) setMinZoom: (float)  minZoom
maxZoom: (float)  maxZoom 

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.

- (GMSCameraPosition *) cameraForBounds: (GMSCoordinateBounds *)  bounds
insets: (UIEdgeInsets)  insets 

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 nil or invalid this method will return a nil camera.

- (void) moveCamera: (GMSCameraUpdate *)  update

Changes the camera according to update.

The camera change is instantaneous (with no animation).

- (void) animateToCameraPosition: (GMSCameraPosition *)  cameraPosition

Animates the camera of this map to cameraPosition.

- (void) animateToLocation: (CLLocationCoordinate2D)  location

As animateToCameraPosition:, but changes only the location of the camera (i.e., from the current location to location).

- (void) animateToZoom: (CGFloat)  zoom

As animateToCameraPosition:, but changes only the zoom level of the camera.

This value is clamped by [kGMSMinZoomLevel, kGMSMaxZoomLevel].

- (void) animateToBearing: (CLLocationDirection)  bearing

As animateToCameraPosition:, but changes only the bearing of the camera (in degrees).

Zero indicates true north.

- (void) animateToViewingAngle: (double)  viewingAngle

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.

- (void) animateWithCameraUpdate: (GMSCameraUpdate *)  cameraUpdate

Applies cameraUpdate to the current camera, and then uses the result as per animateToCameraPosition:.


Property Documentation

- (id<GMSMapViewDelegate>) delegate [read, write, assign]

GMSMapView delegate.

- (GMSCameraPosition*) camera [read, write, copy]

Controls the camera, which defines how the map is oriented.

Modification of this property is instantaneous.

- (GMSProjection*) projection [read, assign]

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.

- (BOOL) myLocationEnabled [read, write, assign]

Controls whether the My Location dot and accuracy circle is enabled.

Defaults to NO.

- (CLLocation*) myLocation [read, assign]

If My Location is enabled, reveals where the user 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.

- (GMSMarker*) selectedMarker [read, write, assign]

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.

- (BOOL) trafficEnabled [read, write, assign]

Controls whether the map is drawing traffic data, if available.

This is subject to the availability of traffic data. Defaults to NO.

- (GMSMapViewType) mapType [read, write, assign]

Controls the type of map tiles that should be displayed.

Defaults to kGMSTypeNormal.

- (float) minZoom [read, assign]

Minimum zoom (the farthest the camera may be zoomed out).

Defaults to kGMSMinZoomLevel. Modified with -setMinZoom:maxZoom:.

- (float) maxZoom [read, assign]

Maximum zoom (the closest the camera may be to the Earth).

Defaults to kGMSMaxZoomLevel. Modified with -setMinZoom:maxZoom:.

- (BOOL) buildingsEnabled [read, write, assign]

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.

- (BOOL) indoorEnabled [read, write, assign]

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.

- (GMSIndoorDisplay*) indoorDisplay [read, assign]

Gets the GMSIndoorDisplay instance which allows to observe or control aspects of indoor data display.

- (GMSUISettings*) settings [read, assign]

Gets the GMSUISettings object, which controls user interface settings for the map.

- (UIEdgeInsets) padding [read, write, assign]

Controls the 'visible' region of the view.

By applying padding an area arround 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.

- (BOOL) accessibilityElementsHidden [read, write, assign]

Defaults to YES.

If set to NO, GMSMapView will generate accessibility elements for overlay objects, such as GMSMarker and GMSPolyline.

This property is as per the informal UIAcessibility protocol, except for the default value of YES.

- (GMSMapLayer*) layer [read, retain]

Accessor for the custom CALayer type used for the layer.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.