mapbox / mapbox-gl-native-ios

Interactive, thoroughly customizable maps for iOS powered by vector tiles and OpenGL
https://www.mapbox.com/mobile/
Other
210 stars 122 forks source link

Display labels only in a given area on the map #290

Closed jeudesprits closed 3 years ago

jeudesprits commented 4 years ago

I would like to hide all labels that go beyond the status bar. Now, labels are displayed directly under the status bar, which sometimes greatly interferes:

image

1ec5 commented 4 years ago

This is a very interesting and reasonable idea. The default visual effect of a UIVisualEffectView, UIVibrancyEffect, is designed to magnify drastic changes in color, which is no problem for most text labels but can be problematic for shields, as you’ve discovered. MapKit apparently does exclude shields from the status bar area, probably by rendering them into a different CALayer.

mapkit

Unfortunately, I’m not sure how we’d go about implementing a mask for just the status bar area, because shields in Mapbox GL are really part of the same base map rendered by OpenGL, not something we can separate into its own CALayer. mapbox/mapbox-gl-js#6267 proposes adding something to the style specification to invert a fill layer. Mapbox GL doesn’t currently support any compositing effects, so we’re limited to approaches that operate on entire features, not individual symbols like shields.

Just brainstorming some workarounds in order of ickiness:

jeudesprits commented 4 years ago

@1ec5

Mapbox GL doesn’t currently support any compositing effects, so we’re limited to approaches that operate on entire features, not individual symbols like shields.

But what if we remove absolutely all labels? Not just shields. Is it possible? Because the problem is not only in shields, but also in rather bold inscriptions.

1ec5 commented 4 years ago

You can hide or remove anything from the style, all the way down to a blank style, by editing the style JSON (such as in Mapbox Studio), calling -[MGLStyle removeLayer:], or setting MGLStyleLayer.visible. You can hide or remove whole layers (e.g., every feature road label) or only features within that layer (e.g., individual highway shields) that match a certain condition. The problem is that the condition can’t be based on whether the feature happens to be at the top of the screen.

stale[bot] commented 3 years ago

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