GMSGeocoder.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // GMSGeocoder.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. #if __has_feature(modules)
  12. @import GoogleMapsBase;
  13. #else
  14. #import <GoogleMapsBase/GoogleMapsBase.h>
  15. #endif
  16. #import <GoogleMaps/GMSAddress.h>
  17. GMS_ASSUME_NONNULL_BEGIN
  18. @class GMSReverseGeocodeResponse;
  19. /** GMSGeocoder error codes, embedded in NSError. */
  20. typedef NS_ENUM(NSInteger, GMSGeocoderErrorCode) {
  21. kGMSGeocoderErrorInvalidCoordinate = 1,
  22. kGMSGeocoderErrorInternal,
  23. };
  24. /** Handler that reports a reverse geocoding response, or error. */
  25. typedef void (^GMSReverseGeocodeCallback)(GMSReverseGeocodeResponse *GMS_NULLABLE_PTR,
  26. NSError *GMS_NULLABLE_PTR);
  27. /**
  28. * Exposes a service for reverse geocoding. This maps Earth coordinates (latitude and longitude) to
  29. * a collection of addresses near that coordinate.
  30. */
  31. @interface GMSGeocoder : NSObject
  32. /* Convenience constructor for GMSGeocoder. */
  33. + (GMSGeocoder *)geocoder;
  34. /**
  35. * Reverse geocodes a coordinate on the Earth's surface.
  36. *
  37. * @param coordinate The coordinate to reverse geocode.
  38. * @param handler The callback to invoke with the reverse geocode results.
  39. * The callback will be invoked asynchronously from the main thread.
  40. */
  41. - (void)reverseGeocodeCoordinate:(CLLocationCoordinate2D)coordinate
  42. completionHandler:(GMSReverseGeocodeCallback)handler;
  43. @end
  44. /** A collection of results from a reverse geocode request. */
  45. @interface GMSReverseGeocodeResponse : NSObject<NSCopying>
  46. /** Returns the first result, or nil if no results were available. */
  47. - (GMSAddress *GMS_NULLABLE_PTR)firstResult;
  48. /** Returns an array of all the results (contains GMSAddress), including the first result. */
  49. - (GMS_NSArrayOf(GMSAddress *) * GMS_NULLABLE_PTR)results;
  50. @end
  51. GMS_ASSUME_NONNULL_END