GoogleMaps Framework Reference

GMSProjection

@interface GMSProjection : NSObject

Defines a mapping between Earth coordinates CLLocationCoordinate2D and coordinates in the map’s view CGPoint. A projection is constant and immutable, in that the mapping it embodies never changes. The mapping is not necessarily linear.

Passing invalid Earth coordinates (i.e., per CLLocationCoordinate2DIsValid) to this object may result in undefined behavior.

This class should not be instantiated directly unless under testing conditions. Instead, obtain it via projection on GMSMapView.

  • Maps an Earth coordinate to a point coordinate in the map’s view.

    Declaration

    Swift

    func point(for coordinate: CLLocationCoordinate2D) -> CGPoint

    Objective-C

    - (CGPoint)pointForCoordinate:(CLLocationCoordinate2D)coordinate;
  • Maps a point coordinate in the map’s view to an Earth coordinate.

    Declaration

    Swift

    func coordinate(for point: CGPoint) -> CLLocationCoordinate2D

    Objective-C

    - (CLLocationCoordinate2D)coordinateForPoint:(CGPoint)point;
  • Converts a distance in meters to content size. This is only accurate for small Earth distances, as it uses CGFloat for screen distances.

    Declaration

    Swift

    func points(forMeters meters: CLLocationDistance, at coordinate: CLLocationCoordinate2D) -> CGFloat

    Objective-C

    - (CGFloat)pointsForMeters:(CLLocationDistance)meters
                  atCoordinate:(CLLocationCoordinate2D)coordinate;
  • Returns whether a given coordinate (lat/lng) is contained within the projection.

    Declaration

    Swift

    func contains(_ coordinate: CLLocationCoordinate2D) -> Bool

    Objective-C

    - (BOOL)containsCoordinate:(CLLocationCoordinate2D)coordinate;
  • Returns the region (four location coordinates) that is visible according to the projection. If padding was set on GMSMapView, this region takes the padding into account.

    The visible region can be non-rectangular. The result is undefined if the projection includes points that do not map to anywhere on the map (e.g., camera sees outer space).

    Declaration

    Swift

    func visibleRegion() -> GMSVisibleRegion

    Objective-C

    - (GMSVisibleRegion)visibleRegion;