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

Hide the ℹ️ attribution button if map isn't interactive #3804

Closed

Description

@friedbunny

When a map view has userInteractionEnabled=NO, the ℹ️ button isn't tappable. It doesn't make much sense to have a non-tappable button, so we should hide it.

When there is no attribution button (or effectively none), we may also want to re-check for a telemetry opt-out.

/cc @1ec5 @boundsj

Activity

  1. added
    iOS
    telemetry
    on Feb 3, 2016
  2. friedbunny commented on Jan 9, 2017

    @friedbunny
    ContributorAuthor

    Instead of just hiding the button, we should switch to text-only attribution in non-interactive maps.

  3. 1ec5 commented on Jan 9, 2017

    @1ec5
    Contributor

    For the textual attribution, most of

    - (void)installAttributionView {
    [_attributionView removeFromSuperview];
    _attributionView = [[NSView alloc] initWithFrame:NSZeroRect];
    _attributionView.wantsLayer = YES;
    // Make the background and foreground translucent to be unobtrusive.
    _attributionView.layer.opacity = 0.6;
    // Blur the background to prevent text underneath the view from running into
    // the text in the view, rendering it illegible.
    CIFilter *attributionBlurFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
    [attributionBlurFilter setDefaults];
    // Brighten the background. This is similar to applying a translucent white
    // background on the view, but the effect is a bit more subtle and works
    // well with the blur above.
    CIFilter *attributionColorFilter = [CIFilter filterWithName:@"CIColorControls"];
    [attributionColorFilter setDefaults];
    [attributionColorFilter setValue:@(0.1) forKey:kCIInputBrightnessKey];
    // Apply the background effects and a standard button corner radius.
    _attributionView.backgroundFilters = @[attributionColorFilter, attributionBlurFilter];
    _attributionView.layer.cornerRadius = 4;
    _attributionView.translatesAutoresizingMaskIntoConstraints = NO;
    [self addSubview:_attributionView];
    [self updateAttributionView];
    }
    and
    - (void)updateAttributionView {
    NSView *attributionView = self.attributionView;
    for (NSView *button in attributionView.subviews) {
    [button removeConstraints:button.constraints];
    }
    attributionView.subviews = @[];
    [attributionView removeConstraints:attributionView.constraints];
    // Make the whole string mini by default.
    // Force links to be black, because the default blue is distracting.
    CGFloat miniSize = [NSFont systemFontSizeForControlSize:NSMiniControlSize];
    NSArray *attributionInfos = [self.style attributionInfosWithFontSize:miniSize linkColor:[NSColor blackColor]];
    for (MGLAttributionInfo *info in attributionInfos) {
    // Feedback links are added to the Help menu.
    if (info.feedbackLink) {
    continue;
    }
    // For each attribution, add a borderless button that responds to clicks
    // and feels like a hyperlink.
    NSButton *button = [[MGLAttributionButton alloc] initWithAttributionInfo:info];
    button.controlSize = NSMiniControlSize;
    button.translatesAutoresizingMaskIntoConstraints = NO;
    // Set the new button flush with the buttom of the container and to the
    // right of the previous button, with standard spacing. If there is no
    // previous button, align to the container instead.
    NSView *previousView = attributionView.subviews.lastObject;
    [attributionView addSubview:button];
    [attributionView addConstraint:
    [NSLayoutConstraint constraintWithItem:button
    attribute:NSLayoutAttributeBottom
    relatedBy:NSLayoutRelationEqual
    toItem:attributionView
    attribute:NSLayoutAttributeBottom
    multiplier:1
    constant:0]];
    [attributionView addConstraint:
    [NSLayoutConstraint constraintWithItem:button
    attribute:NSLayoutAttributeLeading
    relatedBy:NSLayoutRelationEqual
    toItem:previousView ? previousView : attributionView
    attribute:previousView ? NSLayoutAttributeTrailing : NSLayoutAttributeLeading
    multiplier:1
    constant:8]];
    [attributionView addConstraint:
    [NSLayoutConstraint constraintWithItem:button
    attribute:NSLayoutAttributeTop
    relatedBy:NSLayoutRelationEqual
    toItem:attributionView
    attribute:NSLayoutAttributeTop
    multiplier:1
    constant:0]];
    }
    if (attributionInfos.count) {
    [attributionView addConstraint:
    [NSLayoutConstraint constraintWithItem:attributionView
    attribute:NSLayoutAttributeTrailing
    relatedBy:NSLayoutRelationEqual
    toItem:attributionView.subviews.lastObject
    attribute:NSLayoutAttributeTrailing
    multiplier:1
    constant:8]];
    }
    }
    should port pretty straightforwardly to iOS.

  4. added
    archived
    on Nov 16, 2018
  5. stale commented on Nov 24, 2018

    @stale

    This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

  6. removed
    archived
    on Nov 26, 2018
  7. added
    archived
    on May 25, 2019
  8. stale commented on May 25, 2019

    @stale

    This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

  9. removed
    archived
    on May 28, 2019
  10. added
    archived
    on May 20, 2020
  11. stale commented on May 22, 2020

    @stale

    This issue has been automatically detected as stale because it has not had recent activity and will be archived. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    archivedbuggl-iosiOStelemetry

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions