Add extra UI settings and location manager settings. (#3817)

Co-authored-by: Tetiana Gubanova <3168855+TatyanaPolunina@users.noreply.github.com>
This commit is contained in:
Yaroslav
2025-09-19 13:40:05 +03:00
committed by GitHub
parent 9e2084d3a7
commit 8441d1d7de
5 changed files with 89 additions and 2 deletions

View File

@@ -25,6 +25,9 @@ FOUNDATION_EXTERN NSString *const MBXReuseQueueStatsEnabled;
@property (nonatomic) BOOL framerateMeasurementEnabled;
@property (nonatomic) MLNMapDebugMaskOptions debugMask;
@property (nonatomic) BOOL reuseQueueStatsEnabled;
@property (nonatomic) BOOL showsCompassView;
@property (nonatomic) BOOL showsLogoView;
@property (nonatomic) BOOL showsAttributionButton;
@property (nonatomic, readonly) NSString *debugDescription;

View File

@@ -10,6 +10,9 @@ NSString *const MBXShowsMapScale = @"MBXMapShowsScale";
NSString *const MBXMapShowsHeadingIndicator = @"MBXMapShowsHeadingIndicator";
NSString *const MBXMapFramerateMeasurementEnabled = @"MBXMapFramerateMeasurementEnabled";
NSString *const MBXReuseQueueStatsEnabled = @"MBXReuseQueueStatsEnabled";
NSString *const MBXShowsCompassView = @"MBXShowsCompassView";
NSString *const MBXShowsLogoView = @"MBXShowsLogoView";
NSString *const MBXShowsAttributionButton = @"MBXShowsAttributionButton";
@interface MBXState()
@@ -29,6 +32,9 @@ NSString *const MBXReuseQueueStatsEnabled = @"MBXReuseQueueStatsEnabled";
[coder encodeBool:_showsUserHeadingIndicator forKey:MBXMapShowsHeadingIndicator];
[coder encodeBool:_framerateMeasurementEnabled forKey:MBXMapFramerateMeasurementEnabled];
[coder encodeBool:_reuseQueueStatsEnabled forKey:MBXReuseQueueStatsEnabled];
[coder encodeBool:_showsLogoView forKey:MBXShowsLogoView];
[coder encodeBool:_showsCompassView forKey:MBXShowsCompassView];
[coder encodeBool:_showsAttributionButton forKey:MBXShowsAttributionButton];
}
- (nullable instancetype)initWithCoder:(nonnull NSCoder *)decoder {
@@ -43,6 +49,9 @@ NSString *const MBXReuseQueueStatsEnabled = @"MBXReuseQueueStatsEnabled";
BOOL decodedShowsUserHeadingIndicator = [decoder decodeBoolForKey:MBXMapShowsHeadingIndicator];
BOOL decodedFramerateMeasurementEnabled = [decoder decodeBoolForKey:MBXMapFramerateMeasurementEnabled];
BOOL decodedReuseQueueStatsEnabled = [decoder decodeBoolForKey:MBXReuseQueueStatsEnabled];
BOOL decodedShowsLogoView = [decoder decodeBoolForKey:MBXShowsLogoView];
BOOL decodedShowsCompassView = [decoder decodeBoolForKey:MBXShowsCompassView];
BOOL decodedAttributionButton = [decoder decodeBoolForKey:MBXShowsAttributionButton];
_camera = decodedCamera;
_userTrackingMode = decodedUserTrackingMode.intValue;
@@ -54,6 +63,9 @@ NSString *const MBXReuseQueueStatsEnabled = @"MBXReuseQueueStatsEnabled";
_showsUserHeadingIndicator = decodedShowsUserHeadingIndicator;
_framerateMeasurementEnabled = decodedFramerateMeasurementEnabled;
_reuseQueueStatsEnabled = decodedReuseQueueStatsEnabled;
_showsLogoView = decodedShowsLogoView;
_showsCompassView = decodedShowsCompassView;
_showsAttributionButton = decodedAttributionButton;
}
return self;
@@ -64,7 +76,7 @@ NSString *const MBXReuseQueueStatsEnabled = @"MBXReuseQueueStatsEnabled";
}
- (NSString *)debugDescription {
return [NSString stringWithFormat:@"Camera: %@\nTracking mode: %lu\nShows user location: %@\nDebug mask value: %lu\nShows zoom level ornament: %@\nShows time frame graph: %@\nShows map scale: %@\nShows user heading indicator: %@\nFramerate measurement enabled: %@\nReuse queue stats enabled: %@",
return [NSString stringWithFormat:@"Camera: %@\nTracking mode: %lu\nShows user location: %@\nDebug mask value: %lu\nShows zoom level ornament: %@\nShows time frame graph: %@\nShows map scale: %@\nShows user heading indicator: %@\nFramerate measurement enabled: %@\nReuse queue stats enabled: %@\nShows logo view: %@\nShows compass view: %@\nShows attribution button: %@",
self.camera,
(unsigned long)self.userTrackingMode,
self.showsUserLocation ? @"YES" : @"NO",
@@ -74,7 +86,10 @@ NSString *const MBXReuseQueueStatsEnabled = @"MBXReuseQueueStatsEnabled";
self.showsMapScale ? @"YES" : @"NO",
self.showsUserHeadingIndicator ? @"YES" : @"NO",
self.framerateMeasurementEnabled ? @"YES" : @"NO",
self.reuseQueueStatsEnabled ? @"YES" : @"NO"];
self.reuseQueueStatsEnabled ? @"YES" : @"NO",
self.showsLogoView ? @"YES" : @"NO",
self.showsCompassView ? @"YES" : @"NO",
self.showsAttributionButton ? @"YES" : @"NO"];
}
@end

View File

@@ -300,6 +300,9 @@ CLLocationCoordinate2D randomWorldCoordinate(void) {
self.mapView.showsUserHeadingIndicator = YES;
self.mapView.showsScale = YES;
self.mapView.showsLogoView = YES;
self.mapView.showsCompassView = YES;
self.mapView.showsAttributionButton = YES;
self.zoomLevelOrnamentEnabled = NO;
self.frameTimeGraphEnabled = NO;
} else {

View File

@@ -357,6 +357,14 @@ MLN_EXPORT
*/
@property (nonatomic, assign) CGPoint scaleBarMargins;
/**
A Boolean value indicating whether the map may display Compass View.
The view controlled by this property is available at `compassView`. The default value
of this property is `YES`.
*/
@property (nonatomic, assign) BOOL showsCompassView;
/**
A control indicating the map’s direction and allowing the user to manipulate
the direction, positioned in the upper-right corner.
@@ -374,6 +382,14 @@ MLN_EXPORT
*/
@property (nonatomic, assign) CGPoint compassViewMargins;
/**
A Boolean value indicating whether the map may display MapLibre logo.
The view controlled by this property is available at `logoView`. The default value
of this property is `YES`.
*/
@property (nonatomic, assign) BOOL showsLogoView;
/**
A logo, the MapLibre logo by default, positioned in the lower-left corner.
You are not required to display this, but some vector-sources may require attribution.
@@ -391,6 +407,14 @@ MLN_EXPORT
*/
@property (nonatomic, assign) CGPoint logoViewMargins;
/**
A Boolean value indicating whether the map may display Attribution Button.
The view controlled by this property is available at `attributionButton`. The default value
of this property is `YES`.
*/
@property (nonatomic, assign) BOOL showsAttributionButton;
/**
A view showing legally required copyright notices,
positioned at the bottom-right of the map view.
@@ -510,6 +534,11 @@ MLN_EXPORT
// MARK: Displaying the User’s Location
/**
Disabled using a current location manager.
*/
- (void)disableLocationManager;
/**
The object that this map view uses to start and stop the delivery of
location-related updates.

View File

@@ -782,6 +782,10 @@ public:
NSStringFromClass(self.class));
});
_showsLogoView = YES;
_showsCompassView = YES;
_showsAttributionButton = YES;
// setup logo
//
UIImage *logo = [UIImage mgl_resourceImageNamed:@"maplibre-logo-stroke-gray"];
@@ -790,6 +794,7 @@ public:
_logoView.accessibilityLabel = NSLocalizedStringWithDefaultValue(@"LOGO_A11Y_LABEL", nil, nil, @"Mapbox", @"Accessibility label");
_logoView.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_logoView];
_logoView.hidden = !_showsLogoView;
_logoViewConstraints = [NSMutableArray array];
_logoViewPosition = MLNOrnamentPositionBottomLeft;
_logoViewMargins = MLNOrnamentDefaultPositionOffset;
@@ -802,6 +807,7 @@ public:
[_attributionButton addTarget:self action:@selector(showAttribution:) forControlEvents:UIControlEventTouchUpInside];
_attributionButton.translatesAutoresizingMaskIntoConstraints = NO;
[self addSubview:_attributionButton];
_attributionButton.hidden = !_showsAttributionButton;
_attributionButtonConstraints = [NSMutableArray array];
UILongPressGestureRecognizer *attributionLongPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(showAttribution:)];
@@ -813,6 +819,7 @@ public:
//
_compassView = [MLNCompassButton compassButtonWithMapView:self];
[self addSubview:_compassView];
_compassView.hidden = !_showsCompassView;
_compassViewConstraints = [NSMutableArray array];
_compassViewPosition = MLNOrnamentPositionTopRight;
_compassViewMargins = MLNOrnamentDefaultPositionOffset;
@@ -3227,6 +3234,27 @@ static void *windowScreenContext = &windowScreenContext;
}
}
- (void)setShowsLogoView:(BOOL)showsLogoView
{
MLNLogDebug(@"Setting showsLogoView: %@", MLNStringFromBOOL(showsLogoView));
_showsLogoView = showsLogoView;
self.logoView.hidden = !showsLogoView;
}
- (void)setShowsCompassView:(BOOL)showsCompassView
{
MLNLogDebug(@"Setting showsCompassView: %@", MLNStringFromBOOL(showsCompassView));
_showsCompassView = showsCompassView;
self.compassView.hidden = !showsCompassView;
}
- (void)setShowsAttributionButton:(BOOL)showsAttributionButton
{
MLNLogDebug(@"Setting showsAttributionButton: %@", MLNStringFromBOOL(showsAttributionButton));
_showsAttributionButton = showsAttributionButton;
self.attributionButton.hidden = !showsAttributionButton;
}
- (void)setScaleBarShouldShowDarkStyles:(BOOL)scaleBarShouldShowDarkStyles {
_scaleBarShouldShowDarkStyles = scaleBarShouldShowDarkStyles;
@@ -5983,9 +6011,18 @@ static void *windowScreenContext = &windowScreenContext;
// MARK: - User Location -
- (void)disableLocationManager
{
[_locationManager stopUpdatingLocation];
[_locationManager stopUpdatingHeading];
_locationManager = nil;
}
- (void)setLocationManager:(nullable id<MLNLocationManager>)locationManager
{
MLNLogDebug(@"Setting locationManager: %@", locationManager);
if (!locationManager) {
locationManager = [[MLNCLLocationManager alloc] init];
}