diff options
author | Jason Wray <friedbunny@users.noreply.github.com> | 2016-08-16 15:16:59 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-16 15:16:59 -0400 |
commit | f489ec2ee131725b42162edf0414241f9c6310d1 (patch) | |
tree | 87d1621831a3386f49a6d4a47362c59e9a338d21 /platform/ios/src/MGLUserLocationAnnotationView.h | |
parent | 01b94de107de875a6889258e72e5e060c0de0881 (diff) | |
download | qtlocation-mapboxgl-f489ec2ee131725b42162edf0414241f9c6310d1.tar.gz |
[ios] Refactored user location annotation into a customizable class (#5882)
A new class, `MGLUserLocationAnnotationView`, has been added that inherits from `MGLAnnotationView`.
Use a subclass of `MGLUserLocationAnnotationView` to customize the appearance of the user location annotation. Use your custom view with the `MGLMapView.userLocation` annotation via the `-mapView:viewForAnnotation:` delegate method.
Diffstat (limited to 'platform/ios/src/MGLUserLocationAnnotationView.h')
-rw-r--r-- | platform/ios/src/MGLUserLocationAnnotationView.h | 52 |
1 files changed, 43 insertions, 9 deletions
diff --git a/platform/ios/src/MGLUserLocationAnnotationView.h b/platform/ios/src/MGLUserLocationAnnotationView.h index f6b62f2b23..5e0a805f3a 100644 --- a/platform/ios/src/MGLUserLocationAnnotationView.h +++ b/platform/ios/src/MGLUserLocationAnnotationView.h @@ -1,5 +1,6 @@ #import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> +#import <Mapbox/Mapbox.h> #import "MGLTypes.h" @@ -9,15 +10,48 @@ NS_ASSUME_NONNULL_BEGIN @class MGLUserLocation; /** View representing an `MGLUserLocation` on screen. */ -@interface MGLUserLocationAnnotationView : UIView - -@property (nonatomic, weak) MGLMapView *mapView; -@property (nonatomic) MGLUserLocation *annotation; -@property (nonatomic, readonly, nullable) CALayer *haloLayer; -@property (nonatomic, readonly) CALayer *hitTestLayer; - -- (instancetype)initInMapView:(MGLMapView *)mapView NS_DESIGNATED_INITIALIZER; -- (void)setupLayers; +@interface MGLUserLocationAnnotationView : MGLAnnotationView + +/** + Returns the associated map view. + + The value of this property is nil during initialization. + */ +@property (nonatomic, readonly, weak, nullable) MGLMapView *mapView; + +/** + Returns the annotation object indicating the user’s current location. + + The value of this property is nil during initialization and while user tracking + is inactive. + */ +@property (nonatomic, readonly, weak, nullable) MGLUserLocation *userLocation; + +/** + Returns the layer that should be used for annotation selection hit testing. + + The default value of this property is the presentation layer of the view’s Core + Animation layer. When subclassing, you may override this property to specify a + different layer to be used for hit testing. This can be useful when you wish to + limit the interactive area of the annotation to a specific sublayer. + */ +@property (nonatomic, readonly, weak) CALayer *hitTestLayer; + +/** + Updates the user location annotation. + + Use this method to update the appearance of the user location annotation. This + method is called by the associated map view when it has determined that the + user location annotation needs to be updated. This can happen in response to + user interaction, a change in the user’s location, when the user tracking mode + changes, or when the viewport changes. + + @note During user interaction with the map, this method may be called many + times to update the user location annotation. Therefore, your implementation of + this method should be as lightweight as possible to avoid negatively affecting + performance. + */ +- (void)update; @end |