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

Affix user dot on screen in user tracking mode #3589

Merged
merged 13 commits into from
Jan 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ custom_categories:
children:
- MGLAnnotation
- MGLAnnotationImage
- MGLAnnotationVerticalAlignment
- MGLCalloutView
- MGLCalloutViewDelegate
- MGLMultiPoint
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ Known issues:
- A new method on MGLMapView, `-flyToCamera:withDuration:completionHandler:`, lets you transition between viewpoints along an arc as if by aircraft. ([#3171](https://github.com/mapbox/mapbox-gl-native/pull/3171), [#3301](https://github.com/mapbox/mapbox-gl-native/pull/3301))
- MGLMapCamera’s `altitude` values now match those of MKMapCamera. ([#3362](https://github.com/mapbox/mapbox-gl-native/pull/3362))
- MGLMapView properties like `centerCoordinate` and `camera` now offset the center to account for any translucent top or bottom bar. As a result, when user tracking is enabled and the map view is an immediate child of a view controller, the user dot is centered in the unobscured portion of the map view. To override this offset, modify the `contentInset` property; you may also need to set the containing view controller’s `automaticallyAdjustsScrollViewInsets` property to `NO`. ([#3583](https://github.com/mapbox/mapbox-gl-native/pull/3583))
- The user dot’s callout view is now centered above the user dot. It was previously offset slightly to the left. ([#3261](https://github.com/mapbox/mapbox-gl-native/pull/3261))
- In user tracking mode, the user dot stays in a fixed position within MGLMapView while the map pans smoothly. A new property, `userLocationVerticalAlignment`, determines the user dot’s fixed position. ([#3589](https://github.com/mapbox/mapbox-gl-native/pull/3589))
- Zooming and rotation gestures no longer disable user tracking mode. ([#3589](https://github.com/mapbox/mapbox-gl-native/pull/3589))
- User tracking mode starts out at a lower zoom level by default. ([#3589](https://github.com/mapbox/mapbox-gl-native/pull/3589))
- Fixed an issue with small map views not properly fitting annotations within bounds. (#[3407](https://github.com/mapbox/mapbox-gl-native/pull/3407))
- When the user rotates the map to within 7° of true north, the map view now snaps to true north. ([#3403](https://github.com/mapbox/mapbox-gl-native/pull/3403))
- The map view’s background can now be transparent or translucent, as long as the style’s background layer is transparent or translucent and `MGLMapView.opaque` is set to `NO`. ([#3096](https://github.com/mapbox/mapbox-gl-native/pull/3096))
Expand Down
53 changes: 53 additions & 0 deletions include/mbgl/ios/MGLMapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ NS_ASSUME_NONNULL_BEGIN
@protocol MGLOverlay;
@protocol MGLCalloutView;

/** The vertical alignment of an annotation within a map view. */
typedef NS_ENUM(NSUInteger, MGLAnnotationVerticalAlignment) {
/** Aligns the annotation vertically in the center of the map view. */
MGLAnnotationVerticalAlignmentCenter = 0,
/** Aligns the annotation vertically at the top of the map view. */
MGLAnnotationVerticalAlignmentTop,
/** Aligns the annotation vertically at the bottom of the map view. */
MGLAnnotationVerticalAlignmentBottom,
};

/**
An interactive, customizable map view with an interface similar to the one
provided by Apple's MapKit.
Expand Down Expand Up @@ -218,6 +228,24 @@ IB_DESIGNABLE
*/
@property (nonatomic, assign) MGLUserTrackingMode userTrackingMode;

/**
Sets the mode used to track the user location, with an optional transition.

@param mode The mode used to track the user location.
@param animated If `YES`, there is an animated transition from the current
viewport to a viewport that results from the change to `mode`. If `NO`, the
map view instantaneously changes to the new viewport. This parameter only
affects the initial transition; subsequent changes to the user location or
heading are always animated.
*/
- (void)setUserTrackingMode:(MGLUserTrackingMode)mode animated:(BOOL)animated;

/**
The vertical alignment of the user location annotation within the receiver. The
default value is `MGLAnnotationVerticalAlignmentCenter`.
*/
@property (nonatomic, assign) MGLAnnotationVerticalAlignment userLocationVerticalAlignment;

/**
Whether the map view should display a heading calibration alert when necessary.
The default value is `YES`.
Expand Down Expand Up @@ -587,9 +615,34 @@ IB_DESIGNABLE
When the map view’s superview is an instance of `UIViewController` whose
`automaticallyAdjustsScrollViewInsets` property is `YES`, the value of this
property may be overridden at any time.

Changing the value of this property updates the map view immediately. If you
want to animate the change, use the `-setContentInset:animated:` method
instead.
*/
@property (nonatomic, assign) UIEdgeInsets contentInset;

/**
Sets the distance from the edges of the map view’s frame to the edges of the
map view’s logical viewport with an optional transition animation.

When the value of this property is equal to `UIEdgeInsetsZero`, viewport
properties such as `centerCoordinate` assume a viewport that matches the map
view’s frame. Otherwise, those properties are inset, excluding part of the
frame from the viewport. For instance, if the only the top edge is inset, the
map center is effectively shifted downward.

When the map view’s superview is an instance of `UIViewController` whose
`automaticallyAdjustsScrollViewInsets` property is `YES`, the value of this
property may be overridden at any time.

@param contentInset The new values to inset the content by.
@param animated Specify `YES` if you want the map view to animate the change to
the content inset or `NO` if you want the map to inset the content
immediately.
*/
- (void)setContentInset:(UIEdgeInsets)contentInset animated:(BOOL)animated;

#pragma mark Converting Geographic Coordinates

/**
Expand Down
24 changes: 23 additions & 1 deletion include/mbgl/osx/MGLMapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,31 @@ IB_DESIGNABLE
the map center is effectively shifted downward.

When the value of the `automaticallyAdjustsContentInsets` property is `YES`,
the value of this property may be overridden at any time. */
the value of this property may be overridden at any time.

Changing the value of this property updates the map view immediately. If you
want to animate the change, use the `-setContentInsets:animated:` method
instead. */
@property (nonatomic, assign) NSEdgeInsets contentInsets;

/** Sets the distance from the edges of the map view’s frame to the edges of the
map view’s logical viewport, with an optional transition animation.

When the value of this property is equal to `NSEdgeInsetsZero`, viewport
properties such as `centerCoordinate` assume a viewport that matches the map
view’s frame. Otherwise, those properties are inset, excluding part of the
frame from the viewport. For instance, if the only the top edge is inset,
the map center is effectively shifted downward.

When the value of the `automaticallyAdjustsContentInsets` property is `YES`,
the value of this property may be overridden at any time.

@param contentInsets The new values to inset the content by.
@param animated Specify `YES` if you want the map view to animate the change
to the content insets or `NO` if you want the map to inset the content
immediately. */
- (void)setContentInsets:(NSEdgeInsets)contentInsets animated:(BOOL)animated;

#pragma mark Configuring gesture recognition
/** @name Configuring How the User Interacts with the Map */

Expand Down
2 changes: 1 addition & 1 deletion platform/darwin/MGLMapCamera.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ + (instancetype)cameraLookingAtCenterCoordinate:(CLLocationCoordinate2D)centerCo
{
return [[self alloc] initWithCenterCoordinate:centerCoordinate
altitude:distance
pitch:(CGFloat)pitch
pitch:pitch
heading:heading];
}

Expand Down
Loading