WhirlyGlobeViewControllerDelegate
Objective-C
@protocol WhirlyGlobeViewControllerDelegate <NSObject>
Swift
protocol WhirlyGlobeViewControllerDelegate : NSObjectProtocol
Globe View Controller Delegate protocol for getting back selection and tap events.
Fill out the methods in this protocol and assign yourself as a delegate in the WhirlyGlobeViewController to get selection and tap events.
-
Called when the user taps on or near an object.
You’re given the object you passed in originally, such as a MaplyScreenMarker. Most of those objects have userObject properties, which is a good place to stash your own data.
Declaration
Objective-C
- (void)globeViewController:(WhirlyGlobeViewController *_Nonnull)viewC didSelect:(NSObject *_Nonnull)selectedObj;
Swift
optional func globeViewController(_ viewC: WhirlyGlobeViewController, didSelect selectedObj: NSObject)
Parameters
viewC
The view controller where the user selected something.
selectedObj
The Maply object they selected.
-
Called when the user taps on or near an object.
This will call back with the closest object it finds near (or on) where the user tapped.
You’re given the object you passed in originally, such as a MaplyScreenMarker.
This version is called preferentially if it exists. Otherwise globeViewController:didSelect: is called if it exists.
Declaration
Objective-C
- (void)globeViewController:(WhirlyGlobeViewController *_Nonnull)viewC didSelect:(NSObject *_Nonnull)selectedObj atLoc:(MaplyCoordinate)coord onScreen:(CGPoint)screenPt;
Swift
optional func globeViewController(_ viewC: WhirlyGlobeViewController, didSelect selectedObj: NSObject, atLoc coord: MaplyCoordinate, onScreen screenPt: CGPoint)
Parameters
viewC
The view controller where the user selected something.
selectedObj
The Maply object they selected.
coord
The location (geographic lon/lat in radians) where the user tapped.
screenPt
The location on screen where the user tapped.
-
Called when the user taps on or near one or more objects. Returns them all.
This method is called when the
Declaration
Objective-C
- (void)globeViewController:(WhirlyGlobeViewController *_Nonnull)viewC allSelect:(NSArray *_Nonnull)selectedObjs atLoc:(MaplyCoordinate)coord onScreen:(CGPoint)screenPt;
Swift
optional func globeViewController(_ viewC: WhirlyGlobeViewController, allSelect selectedObjs: [Any], atLoc coord: MaplyCoordinate, onScreen screenPt: CGPoint)
Parameters
viewC
The view controller where the user selected something.
selectedObjs
A list of
coord
The location (geographic lon/lat in radians) where the user tapped.
screenPt
The location on screen where the user tapped.
-
Called when the user taps outside the globe.
Declaration
Objective-C
- (void)globeViewControllerDidTapOutside: (WhirlyGlobeViewController *_Nonnull)viewC;
Swift
optional func globeViewControllerDidTapOutside(_ viewC: WhirlyGlobeViewController)
-
Called when the user taps the globe but doesn’t select anything.
Declaration
Objective-C
- (void)globeViewController:(WhirlyGlobeViewController *_Nonnull)viewC didTapAt:(MaplyCoordinate)coord;
Swift
optional func globeViewController(_ viewC: WhirlyGlobeViewController, didTapAt coord: MaplyCoordinate)
Parameters
viewC
The view controller where the user selected something.
coord
The location (geographic lon/lat in radians) where the user tapped.
-
This is an older method called when some layers load.
Certain image layers call this method when they finish loading. More modern layers don’t, so don’t rely on this.
Declaration
Objective-C
- (void)globeViewController:(WhirlyGlobeViewController *_Nonnull)viewC layerDidLoad:(WGViewControllerLayer *_Nonnull)layer;
Swift
optional func globeViewController(_ viewC: WhirlyGlobeViewController, layerDidLoad layer: WGViewControllerLayer)
-
Called when the globe starts moving.
This is called when something (probably the user) starts moving the globe.
Declaration
Objective-C
- (void)globeViewControllerDidStartMoving: (WhirlyGlobeViewController *_Nonnull)viewC userMotion:(_Bool)userMotion;
Swift
optional func globeViewControllerDidStartMoving(_ viewC: WhirlyGlobeViewController, userMotion: Bool)
Parameters
viewC
The globe view controller.
userMotion
Set if this is motion being caused by the user, rather than a call to set location.
-
Called when the globe stops moving.
This is called when the globe stops moving. It passes in the corners of the current viewspace.
Declaration
Objective-C
- (void)globeViewController:(WhirlyGlobeViewController *_Nonnull)viewC didStopMoving:(MaplyCoordinate *_Nonnull)corners userMotion:(_Bool)userMotion;
Swift
optional func globeViewController(_ viewC: WhirlyGlobeViewController, didStopMoving corners: UnsafeMutablePointer<MaplyCoordinate>, userMotion: Bool)
Parameters
viewC
The globe view controller.
userMotion
Set if this is motion being caused by the user, rather than a call to set location.
corners
An array of length 4 containing the corners of the view space (lower left, lower right, upper right, upper left). If any of those corners does not intersect the globe (think zoomed out), its values are set to MAXFLOAT.
-
Called when an animation that knows where it’s going to stop start ups.
This is called when we know where the globe will stop. It passes in the corners of that future viewspace.
Declaration
Objective-C
- (void)globeViewController:(WhirlyGlobeViewController *_Nonnull)viewC willStopMoving:(MaplyCoordinate *_Nonnull)corners userMotion:(_Bool)userMotion;
Swift
optional func globeViewController(_ viewC: WhirlyGlobeViewController, willStopMoving corners: UnsafeMutablePointer<MaplyCoordinate>, userMotion: Bool)
Parameters
viewC
The globe view controller.
corners
An array of length 4 containing the corners of the view space (lower left, lower right, upper right, upper left). If any of those corners does not intersect the globe (think zoomed out), its values are set to MAXFLOAT.
userMotion
Set if this is motion being caused by the user, rather than a call to set location.
-
Called whenever the viewpoint moves.
This is called whenever the viewpoint moves. That includes user motion as well as animations.
It may be triggered as often as every frame. If that’s a problem, use the globeViewController:didStopMoving:userMotion: or globeViewController:willStopMoving:userMotion: calls.
Declaration
Objective-C
- (void)globeViewController:(WhirlyGlobeViewController *_Nonnull)viewC didMove:(MaplyCoordinate *_Nonnull)corners;
Swift
optional func globeViewController(_ viewC: WhirlyGlobeViewController, didMove corners: UnsafeMutablePointer<MaplyCoordinate>)
Parameters
viewC
The globe view controller.
corners
An array of length 4 containing the corners of the view space (lower left, lower right, upper right, upper left). If any of those corners does not intersect the globe (think zoomed out), its values are set to MAXFLOAT.