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

Derive attribution from sources in current style #2723

Closed
kkaefer opened this issue Oct 22, 2015 · 11 comments
Closed

Derive attribution from sources in current style #2723

kkaefer opened this issue Oct 22, 2015 · 11 comments
Assignees
Labels
Android Mapbox Maps SDK for Android feature

Comments

@kkaefer
Copy link
Contributor

kkaefer commented Oct 22, 2015

We should implement callbacks that notify the embedding applications of changes in attributions. Attributions are included in Sources, and they may change when enabling/disabling tiles from a source depending on the stylesheet, or when setting a new stylesheet that includes different sources.

@tmpsantos
Copy link
Contributor

👍

@1ec5 1ec5 added this to the ios-future milestone Aug 12, 2016
@1ec5
Copy link
Contributor

1ec5 commented Aug 12, 2016

This is unblocked now that the runtime source API has landed (#5368). The SDKs already manage attribution for the application, so the callback would be provided by the SDK rather than the application.

Each SDK will need to intelligently display the attribution string stored in mbgl::Tileset::attribution. Unfortunately, the attribution string embedded in TileJSON is either literal text or HTML source code (usually the latter) rather than structured data:

<a href="https://www.mapbox.com/about/maps/" target="_blank">&copy; Mapbox</a> <a href="http://www.openstreetmap.org/about/" target="_blank">&copy; OpenStreetMap</a> <a class="mapbox-improve-map" href="https://www.mapbox.com/map-feedback/" target="_blank">Improve this map</a>

We definitely don’t want to display this HTML source code verbatim in the UI, so we’ll need to do some parsing at the SDK level.

On iOS, we currently display attribution in an action sheet, with two hard-coded buttons, labeled “© Mapbox” and “© OpenStreetMap” , that open the appropriate URLs. There is also an “Improve This Map” button.

ios

On macOS, we display attribution much as GL JS does, but implemented as a row of NSButtons that open the appropriate URLs. On each button, the text is underlined except for the copyright symbol, for aesthetic reasons. “Improve This Map” isn’t currently built into the SDK (#5775), but it would go in the Help menu rather than beside the attribution.

macOS

On both iOS and macOS, we can convert the HTML string into an NSAttributedString using a built-in API (that uses WebKit under the hood). Then we can enumerate the links inside the attributed string, spitting out an action button or NSButton. We’d need special cases for copyright symbols and the redundant “Improve This Map” button.

/cc @pveugen @friedbunny

@kkaefer
Copy link
Contributor Author

kkaefer commented Aug 12, 2016

Maybe it's time to update the TileJSON specification and augment the attribution field with a more structured approach to different attribution sources. Also, instead of specifying this globally in the TileJSON file, we should also consider moving this to the individual vector tiles so that we can show the correct attribution for the currently visible tiles given that many tilesets contain a mix of different data sources in different locations.

@friedbunny
Copy link
Contributor

friedbunny commented Aug 12, 2016

@1ec5 As you said, convention on platforms with larger viewport sizes (e.g., desktop and web) is to show these copyright notices directly on the map. I’m not sure if you’re suggesting we do that on mobile, but if so, I don’t think that’s feasible.

On iOS, I’d love to replace the current actionsheet with something better: a custom view, which would allow us more control over appearance and content. We’ve not gone the custom view route because of worries about polluting the host application’s view hierarchy (or making incorrect assumptions about it), but perhaps we should investigate this again.

@1ec5
Copy link
Contributor

1ec5 commented Aug 12, 2016

On iOS, the problem with a modal view remains: that it’ll either be boxed in by the map view (which can be relatively small), making it not really a modal, or it’ll hitch onto the host view controller, which opens the SDK up to all sorts of fragility because not everyone displays a full-screen map view alone in a view controller.

In any case, changing the presentation of attribution is out of scope for this ticket. #2723 (comment) is simply about detailing the requirements for the current presentation on each platform, and how we’d achieve “data-driven” attribution instead of the hard-coded attribution we have now.

@friedbunny
Copy link
Contributor

the requirements for the current presentation on each platform

Agreed that we can have a specific design discussion later. @kkaefer’s suggestions sound sufficiently modular and we should be able to make better decisions if/once that is available.

@1ec5 1ec5 mentioned this issue Aug 13, 2016
9 tasks
@1ec5
Copy link
Contributor

1ec5 commented Aug 13, 2016

The structured attribution proposed for TileJSON in #2723 (comment) would be a welcome change. In the meantime, in #5999, I’ve implemented dynamic attribution that parses the HTML source code provided by existing TileJSON documents.

@1ec5
Copy link
Contributor

1ec5 commented Aug 13, 2016

Tracking structured attribution in TileJSON in mapbox/tilejson-spec#20.

1ec5 added a commit that referenced this issue Aug 16, 2016
Implemented observer callbacks so the style knows when the source’s attribution changes and the map knows when the style’s attribution changes. Also implemented a getter for a tile source’s attribution.

Fixes #2723.
1ec5 added a commit that referenced this issue Aug 22, 2016
Implemented observer callbacks so the style knows when the source’s attribution changes and the map knows when the style’s attribution changes. Also implemented a getter for a tile source’s attribution.

Fixes #2723.
1ec5 added a commit that referenced this issue Sep 22, 2016
Implemented observer callbacks so the style knows when the source’s attribution changes and the map knows when the style’s attribution changes. Also implemented a getter for a tile source’s attribution.

Fixes #2723.
1ec5 added a commit that referenced this issue Sep 22, 2016
Implemented observer callbacks so the style knows when the source’s attribution changes and the map knows when the style’s attribution changes. Also implemented a getter for a tile source’s attribution.

Fixes #2723.
1ec5 added a commit that referenced this issue Sep 22, 2016
Implemented observer callbacks so the style knows when the source’s attribution changes and the map knows when the style’s attribution changes. Also implemented a getter for a tile source’s attribution.

Fixes #2723.
1ec5 added a commit that referenced this issue Sep 26, 2016
Implemented observer callbacks so the style knows when the source’s attribution changes and the map knows when the style’s attribution changes. Also implemented a getter for a tile source’s attribution.

Fixes #2723.
@1ec5 1ec5 closed this as completed in f307652 Sep 26, 2016
@1ec5
Copy link
Contributor

1ec5 commented Nov 29, 2016

Reopening to track SDK-level support for this feature:

/cc @tobrun

@1ec5 1ec5 reopened this Nov 29, 2016
@1ec5 1ec5 removed this from the ios-future milestone Nov 29, 2016
@1ec5 1ec5 added the Android Mapbox Maps SDK for Android label Nov 29, 2016
@1ec5 1ec5 changed the title Source attribution callbacks Derive attribution from sources in current style Dec 4, 2016
@1ec5
Copy link
Contributor

1ec5 commented Dec 9, 2016

Fixed for iOS and macOS in #5999.

@zugaldia zugaldia added this to the android-future milestone Jan 19, 2017
@tobrun tobrun modified the milestones: android-v5.1.0, android-future Apr 4, 2017
@tobrun tobrun self-assigned this Apr 4, 2017
@tobrun
Copy link
Member

tobrun commented Apr 4, 2017

PR enabling this for android in #8630

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android feature
Projects
None yet
Development

No branches or pull requests

7 participants