You're all set!

To start developing, please head over to our developer documentation.

Activate the Google Maps SDK for iOS

To get you started we'll guide you through the Google Developers Console to do a few things first:

  1. Create or choose a project
  2. Activate the Google Maps SDK for iOS
  3. Create appropriate keys
Continue

GMSMarker Class Reference

GMSMarker Class Reference

Overview

A marker is an icon placed at a particular point on the map's surface.

A marker's icon is drawn oriented against the device's screen rather than the map's surface; i.e., it will not necessarily change orientation due to map rotations, tilting, or zooming.

Inherits GMSOverlay.

Static Public Member Functions

(instancetype) + markerWithPosition:
 Convenience constructor for a default marker.
(UIImage *) + markerImageWithColor:
 Creates a tinted version of the default marker image for use as an icon.

Properties

CLLocationCoordinate2D position
 Marker position.
NSString *_Nullable snippet
 Snippet text, shown beneath the title in the info window when selected.
UIImage *_Nullable icon
 Marker icon to render.
UIView *_Nullable iconView
 Marker view to render.
BOOL tracksViewChanges
 Controls whether the icon for this marker should be redrawn every frame.
BOOL tracksInfoWindowChanges
 Controls whether the info window for this marker should be redrawn every frame.
CGPoint groundAnchor
 The ground anchor specifies the point in the icon image that is anchored to the marker's position on the Earth's surface.
CGPoint infoWindowAnchor
 The info window anchor specifies the point in the icon image at which to anchor the info window, which will be displayed directly above this point.
GMSMarkerAnimation appearAnimation
 Controls the animation used when this marker is placed on a GMSMapView (default kGMSMarkerAnimationNone, no animation).
BOOL draggable
 Controls whether this marker can be dragged interactively (default NO).
BOOL flat
 Controls whether this marker should be flat against the Earth's surface (YES) or a billboard facing the camera (NO, default).
CLLocationDegrees rotation
 Sets the rotation of the marker in degrees clockwise about the marker's anchor point.
float opacity
 Sets the opacity of the marker, between 0 (completely transparent) and 1 (default) inclusive.
id _Nullable userData
 Marker data.
GMSMarkerLayerlayer
 Provides the Core Animation layer for this GMSMarker.
GMSPanoramaView *_Nullable panoramaView
 The panoramaView specifies which panorama view will attempt to show this marker.
NSString *_Nullable title
 Title, a short description of the overlay.
GMSMapView *_Nullable map
 The map this overlay is on.
BOOL tappable
 If this overlay should cause tap notifications.
int zIndex
 Higher zIndex value overlays will be drawn on top of lower zIndex value tile layers and overlays.

Member Function Documentation

+ (instancetype) markerWithPosition: (CLLocationCoordinate2D)  position

Convenience constructor for a default marker.

+ (UIImage *) markerImageWithColor: (UIColor *_Nullable)  color

Creates a tinted version of the default marker image for use as an icon.


Property Documentation

- (CLLocationCoordinate2D) position [read, write, assign]

Marker position.

Animated.

- (NSString* _Nullable) snippet [read, write, copy]

Snippet text, shown beneath the title in the info window when selected.

- (UIImage* _Nullable) icon [read, write, assign]

Marker icon to render.

If left nil, uses a default SDK place marker.

Supports animated images, but each frame must be the same size or the behavior is undefined.

Supports the use of alignmentRectInsets to specify a reduced tap area. This also redefines how anchors are specified. For an animated image the value for the animation is used, not the individual frames.

- (UIView* _Nullable) iconView [read, write, assign]

Marker view to render.

If left nil, falls back to the icon property instead.

Supports animation of all animatable properties of UIView, except frame and center. Changing these properties or their corresponding CALayer version, including position, is not supported.

Note that the view behaves as if clipsToBounds is set to YES, regardless of its actual value.

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

Controls whether the icon for this marker should be redrawn every frame.

Note that when this changes from NO to YES, the icon is guaranteed to be redrawn next frame.

Defaults to YES. Has no effect if iconView is nil.

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

Controls whether the info window for this marker should be redrawn every frame.

Note that when this changes from NO to YES, the info window is guaranteed to be redrawn next frame.

Defaults to NO.

- (CGPoint) groundAnchor [read, write, assign]

The ground anchor specifies the point in the icon image that is anchored to the marker's position on the Earth's surface.

This point is specified within the continuous space [0.0, 1.0] x [0.0, 1.0], where (0,0) is the top-left corner of the image, and (1,1) is the bottom-right corner.

If the image has non-zero alignmentRectInsets, the top-left and bottom-right mentioned above refer to the inset section of the image.

- (CGPoint) infoWindowAnchor [read, write, assign]

The info window anchor specifies the point in the icon image at which to anchor the info window, which will be displayed directly above this point.

This point is specified within the same space as groundAnchor.

- (GMSMarkerAnimation) appearAnimation [read, write, assign]

Controls the animation used when this marker is placed on a GMSMapView (default kGMSMarkerAnimationNone, no animation).

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

Controls whether this marker can be dragged interactively (default NO).

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

Controls whether this marker should be flat against the Earth's surface (YES) or a billboard facing the camera (NO, default).

- (CLLocationDegrees) rotation [read, write, assign]

Sets the rotation of the marker in degrees clockwise about the marker's anchor point.

The axis of rotation is perpendicular to the marker. A rotation of 0 corresponds to the default position of the marker. Animated.

When the marker is flat on the map, the default position is north aligned and the rotation is such that the marker always remains flat on the map. When the marker is a billboard, the default position is pointing up and the rotation is such that the marker is always facing the camera.

- (float) opacity [read, write, assign]

Sets the opacity of the marker, between 0 (completely transparent) and 1 (default) inclusive.

- (id _Nullable) userData [read, write, assign]

Marker data.

You can use this property to associate an arbitrary object with this marker. Google Maps SDK for iOS neither reads nor writes this property.

Note that userData should not hold any strong references to any Maps objects, otherwise a loop may be created (preventing ARC from releasing objects).

- (GMSMarkerLayer*) layer [read, assign]

Provides the Core Animation layer for this GMSMarker.

- (GMSPanoramaView* _Nullable) panoramaView [read, write, assign]

The panoramaView specifies which panorama view will attempt to show this marker.

Note that if the marker's position is too far away from the panoramaView's current panorama location, it will not be displayed as it will be too small. Can be set to nil to remove the marker from any current panorama view it is attached to. A marker can be shown on both a panorama and a map at the same time.

- (NSString* _Nullable) title [read, write, copy, inherited]

Title, a short description of the overlay.

Some overlays, such as markers, will display the title on the map. The title is also the default accessibility text.

- (GMSMapView* _Nullable) map [read, write, assign, inherited]

The map this overlay is on.

Setting this property will add the overlay to the map. Setting it to nil removes this overlay from the map. An overlay may be active on at most one map at any given time.

- (BOOL) tappable [read, write, assign, inherited]

If this overlay should cause tap notifications.

Some overlays, such as markers, will default to being tappable.

- (int) zIndex [read, write, assign, inherited]

Higher zIndex value overlays will be drawn on top of lower zIndex value tile layers and overlays.

Equal values result in undefined draw ordering. Markers are an exception that regardless of zIndex, they will always be drawn above tile layers and other non-marker overlays; they are effectively considered to be in a separate z-index group compared to other overlays.

Send feedback about...

Google Maps SDK for iOS
Google Maps SDK for iOS
Need help? Visit our support page.