Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Very rough first pass at porting user dot
Browse files Browse the repository at this point in the history
from mapbox/mapbox-ios-sdk

Nothing shows up yet, and accuracy circle annotation and delegate methods are commented out.

Ref #756.
  • Loading branch information
1ec5 committed Mar 10, 2015
1 parent 39e2e51 commit 50379c3
Show file tree
Hide file tree
Showing 8 changed files with 825 additions and 3 deletions.
2 changes: 2 additions & 0 deletions gyp/platform-ios.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
'../include/mbgl/ios/MGLAnnotationView.h',
'../platform/ios/MGLAnnotationView_Private.h',
'../platform/ios/MGLAnnotationView.m',
'../platform/ios/MGLUserLocationAnnotationView.h',
'../platform/ios/MGLUserLocationAnnotationView.m',
'../include/mbgl/ios/MGLStyleFunctionValue.h',
'../platform/ios/MGLStyleFunctionValue.m',
'../include/mbgl/ios/MGLTypes.h',
Expand Down
1 change: 1 addition & 0 deletions include/mbgl/ios/MGLAnnotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>

@protocol MGLAnnotation <NSObject, NSCopying>

Expand Down
29 changes: 28 additions & 1 deletion include/mbgl/ios/MGLMapView.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>

@class MGLAnnotationView;
typedef NS_ENUM(NSUInteger, MGLUserTrackingMode) {
MGLUserTrackingModeNone = 0,
MGLUserTrackingModeFollow = 1,
MGLUserTrackingModeFollowWithHeading = 2
};

@class MGLAnnotationView, MGLUserLocationAnnotationView;
@protocol MGLMapViewDelegate, MGLAnnotation;

/** An MGLMapView object provides an embeddable map interface, similar to the one provided by Apple's MapKit. You use this class to display map information and to manipulate the map contents from your application. You can center the map on a given coordinate, specify the size of the area you want to display, and style the features of the map to fit your application's use case.
Expand Down Expand Up @@ -187,6 +193,27 @@
- (void)removeAnnotation:(id <MGLAnnotation>)annotation;
- (void)removeAnnotations:(NSArray *)annotations;

#pragma mark - Locating the user

/** A Boolean value indicating whether the map may display the user location.
This property does not indicate whether the user’s position is actually visible on the map, only whether the map view is allowed to display it. To determine whether the user’s position is visible, use the userLocationVisible property. The default value of this property is `NO`.
Setting this property to `YES` causes the map view to use the Core Location framework to find the current location. As long as this property is `YES`, the map view continues to track the user’s location and update it periodically.
On iOS 8 and above, your app must specify a value for `NSLocationWhenInUseUsageDescription` in its `Info.plist` to satisfy the requirements of the underlying Core Location framework when enabling this property.
*/
@property (nonatomic, assign) BOOL showsUserLocation;

/** The annotation object representing the user’s current location. (read-only) */
@property (nonatomic, strong, readonly) MGLUserLocationAnnotationView *userLocationAnnotationView;

/** The mode used to track the user location. */
@property (nonatomic, assign) MGLUserTrackingMode userTrackingMode;

/** Whether the map view should display a heading calibration alert when necessary. The default value is `YES`. */
@property (nonatomic, assign) BOOL displayHeadingCalibration;

#pragma mark - Debugging

/** @name Debugging */
Expand Down
1 change: 1 addition & 0 deletions ios/app/MBXViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ - (void)viewDidLoad
settings = new mbgl::Settings_NSUserDefaults();
[self restoreState:nil];

self.mapView.userTrackingMode = MGLUserTrackingModeFollowWithHeading;
[self.mapView setCenterCoordinate:CLLocationCoordinate2DMake(37.776, -122.412) zoomLevel:14.5 animated:NO];
}

Expand Down
6 changes: 5 additions & 1 deletion platform/ios/MGLAnnotationView.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ - (void)commonInit {
- (void)didMoveToSuperview {
[super didMoveToSuperview];

[self.superview addSubview:self.calloutView];
if (self.superview) {
[self.superview addSubview:self.calloutView];
} else {
[self.calloutView removeFromSuperview];
}
}

@end
Loading

0 comments on commit 50379c3

Please sign in to comment.