GMSProjection.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // GMSProjection.h
  3. // Google Maps SDK for iOS
  4. //
  5. // Copyright 2012 Google Inc.
  6. //
  7. // Usage of this SDK is subject to the Google Maps/Google Earth APIs Terms of
  8. // Service: https://developers.google.com/maps/terms
  9. //
  10. #import <CoreLocation/CoreLocation.h>
  11. /**
  12. * GMSVisibleRegion contains the four points defining the polygon that is visible in a map's camera.
  13. *
  14. * This polygon can be a trapezoid instead of a rectangle, because a camera can have tilt. If the
  15. * camera is directly over the center of the camera, the shape is rectangular, but if the camera is
  16. * tilted, the shape will appear to be a trapezoid whose smallest side is closest to the point of
  17. * view.
  18. */
  19. typedef struct {
  20. /** Bottom left corner of the camera. */
  21. CLLocationCoordinate2D nearLeft;
  22. /** Bottom right corner of the camera. */
  23. CLLocationCoordinate2D nearRight;
  24. /** Far left corner of the camera. */
  25. CLLocationCoordinate2D farLeft;
  26. /** Far right corner of the camera. */
  27. CLLocationCoordinate2D farRight;
  28. } GMSVisibleRegion;
  29. /**
  30. * Defines a mapping between Earth coordinates (CLLocationCoordinate2D) and coordinates in the map's
  31. * view (CGPoint). A projection is constant and immutable, in that the mapping it embodies never
  32. * changes. The mapping is not necessarily linear.
  33. *
  34. * Passing invalid Earth coordinates (i.e., per CLLocationCoordinate2DIsValid) to this object may
  35. * result in undefined behavior.
  36. *
  37. * This class should not be instantiated directly, instead, obtained via projection on GMSMapView.
  38. */
  39. @interface GMSProjection : NSObject
  40. /** Maps an Earth coordinate to a point coordinate in the map's view. */
  41. - (CGPoint)pointForCoordinate:(CLLocationCoordinate2D)coordinate;
  42. /** Maps a point coordinate in the map's view to an Earth coordinate. */
  43. - (CLLocationCoordinate2D)coordinateForPoint:(CGPoint)point;
  44. /**
  45. * Converts a distance in meters to content size. This is only accurate for small Earth distances,
  46. * as it uses CGFloat for screen distances.
  47. */
  48. - (CGFloat)pointsForMeters:(CLLocationDistance)meters
  49. atCoordinate:(CLLocationCoordinate2D)coordinate;
  50. /**
  51. * Returns whether a given coordinate (lat/lng) is contained within the projection.
  52. */
  53. - (BOOL)containsCoordinate:(CLLocationCoordinate2D)coordinate;
  54. /**
  55. * Returns the region (four location coordinates) that is visible according to the projection. If
  56. * padding was set on GMSMapView, this region takes the padding into account.
  57. *
  58. * The visible region can be non-rectangular. The result is undefined if the projection includes
  59. * points that do not map to anywhere on the map (e.g., camera sees outer space).
  60. */
  61. - (GMSVisibleRegion)visibleRegion;
  62. @end