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

[macos, ios] Insert layer above #6730

Closed
wants to merge 2 commits into from
Closed

[macos, ios] Insert layer above #6730

wants to merge 2 commits into from

Conversation

frederoni
Copy link
Contributor

@frederoni frederoni commented Oct 18, 2016

WIP
Insert layer above another layer

@frederoni frederoni added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS Core The cross-platform C++ core, aka mbgl labels Oct 18, 2016
@mention-bot
Copy link

@frederoni, thanks for your PR! By analyzing the history of the files in this pull request, we identified @incanus, @1ec5 and @jfirebaugh to be potential reviewers.

@@ -159,6 +159,7 @@ class Map : private util::noncopyable {
// Layers
style::Layer* getLayer(const std::string& layerID);
void addLayer(std::unique_ptr<style::Layer>, const optional<std::string>& beforeLayerID = {});
Copy link
Contributor Author

@frederoni frederoni Oct 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I remove the optional beforeLayerID and combine beforeOrAfter in the insert method?

@frederoni frederoni force-pushed the fred-insert-layer branch 3 times, most recently from f066a0f to c5e9f9b Compare October 18, 2016 12:31
@jfirebaugh
Copy link
Contributor

jfirebaugh commented Oct 18, 2016

I don't think an additional variant of addLayer is necessary; this should use the beforeLayerID parameter of the existing addLayer method to accomplish the desired result. If this requires calculating which layer is currently immediately after a given layer, you may need #6097 to land first.

@jfirebaugh
Copy link
Contributor

In fact, I question whether the SDKs themselves should have another variant. Typically array-like datastructures offer only an "insert before" operation. In cases where "insert after" is desired, you increment your index by one.

@frederoni
Copy link
Contributor Author

I think you're right about addLayer being sufficient and waiting for #6097 but it does make sense to support this in the SDK. -[UIView insertSubview:aboveSubview:] -[CALayer insertSublayer:above:] is convenient and used quite frequently. Adding a navigation line on top of all roads makes more sense than adding it under symbol layers for example.

@frederoni frederoni closed this Oct 18, 2016
@incanus
Copy link
Contributor

incanus commented Oct 20, 2016

Another vote here for the Cocoa API-like above variant as well. It's a common pattern on iOS.

@jfirebaugh
Copy link
Contributor

As a cartographic convention, it's much more common to say "add a layer beneath labels" than "add a layer above X", for some value of X. We can of course support both in an SDK for a platform where "above" is common in other contexts, I'm just not really convinced it makes sense for map layers.

@frederoni
Copy link
Contributor Author

frederoni commented Oct 21, 2016

Not sure we should confuse cartographers with app developers. One of the most common use cases will likely be to find a road or a park and insert a layer on top of it. If we don't support this, you'll have to find an arbitrary layer above the layer you're working with and insert it beneath it. Doesn't sound very intuitive to me.

@1ec5
Copy link
Contributor

1ec5 commented Oct 21, 2016

For comparison, MapKit only allows you to insert an overlay at one of two preset levels: aboveRoads (above roads; below labels, shields, and POIs) and aboveLabels (above labels, shields, and POIs; below annotations and 3D buildings).

@frederoni
Copy link
Contributor Author

@1ec5 Excellent solution. Let's do something along those lines adapted for custom styles when #6097 lands.

@1ec5
Copy link
Contributor

1ec5 commented Oct 21, 2016

I only pointed out MapKit's overlay levels for comparison, as a window into the most common use cases. Since our SDK is much more freeform, allowing arbitrary styles with arbitrary layers, an equivalent set of options would necessarily be limited to a certain set of Mapbox styles, something we haven't done in the SDK to date.

@1ec5 1ec5 mentioned this pull request Nov 22, 2016
9 tasks
@jfirebaugh jfirebaugh deleted the fred-insert-layer branch December 12, 2016 18:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Core The cross-platform C++ core, aka mbgl iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants