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.

Add View Annotations Z ordering #5238

Closed

Description

@tobrun

We have been hearing about the need to be able to order Markers. For View based Markers an end developer should be able to indicate to a marker to be placed on top of another marker. This system must integrate with other already shown View elements as CompasView, MyLocationView etc. This could be made part or based on current implementation of MarkerViewAdapter, as a separate ViewOverlay implementation or exposed in Marker itself.

This should solve the issues we have been seeing related to overlapping views.
This issue doesn't cover z-ordering or layering from core in #991

Activity

  1. added
    Android
    annotations
    on Jun 4, 2016
  2. added this to the android-v4.2.0 milestone on Jun 4, 2016
  3. tobrun commented on Jun 6, 2016

    @tobrun
    MemberAuthor

    Instead of calling it layers, the term Overlay is more appropriate. This naming doesn't conflict with the layers we have in core and the view based components will always be on top of the map (overlain on top of the map).

  4. tobrun commented on Jun 6, 2016

    @tobrun
    MemberAuthor

    This should solve the issues we have been seeing related to overlapping views.

    If you currently pan an MarkerView towards the CompassView you will see that the MarkerView goes over the CompassView instead of going underneath.

  5. zugaldia commented on Jun 8, 2016

    @zugaldia
    Member

    Related: #5285 (Android equivalent of #991).

  6. tobrun commented on Jun 14, 2016

    @tobrun
    MemberAuthor

    @ivovandongen has been picking related items up in #5298 & #5294.
    We need to validate if those fixes fulfil the requirements of this ticket.

  7. zugaldia commented on Jun 14, 2016

    @zugaldia
    Member

    @tobrun These are limited scale implementation of this ticket.

    In particular, #5294 only brings the selected marker to front, which is a common usecase for the larger need for Z-ordering. iOS recently did the same with #991.

  8. tobrun commented on Jun 16, 2016

    @tobrun
    MemberAuthor

    Moving this of the milestone, what we want for 4.1.0 is in place.
    TBD what we want to add in future releases.

  9. removed this from the android-v4.1.0 milestone on Jun 16, 2016
  10. zugaldia commented on Jun 16, 2016

    @zugaldia
    Member

    Moving this of the milestone, what we want for 4.1.0 is in place.

    👍

  11. tobrun commented on Jun 23, 2016

    @tobrun
    MemberAuthor

    A user reached out in #5451 requesting the possibility to assign a MarkerView to a layer and manipulate layers completely (eg. hide a layer).

  12. 20 remaining items

  13. tobrun commented on Aug 24, 2016

    @tobrun
    MemberAuthor

    Above comment solves the use-case of ordering different types of MarkerViews, it doesn't encapsulate ordering the same type of MarkerViews. My first attempt will involve using float as z index, this will determine the order how the children are drawn. Since this involves dispatching the draw calls ourselves, we might need to look into create are own ViewGroup and make it possible to do order based on the zIndex value of the MarkerViews.

    The difficult part to this system is that views can be recycled when the viewport changes and these need to be restored in correct drawing order. Probably this will result doing the ordering during drawing what could result in a performance hit.

  14. zugaldia commented on Aug 24, 2016

    @zugaldia
    Member

    Put it other words, a collection of markers should be able to be shown on top or bellow another collection of markers.

    I like this approach, even if it's a first iteration. It's consistent with what we do in the Runtime Style API where the z-ordering is attached to the layer, not the annotations. In this case, the adapter (if I understand correctly) would be the equivalent of the layer.

    Looking good.

  15. tobrun commented on Aug 26, 2016

    @tobrun
    MemberAuthor

    Been testing out the concept of changing the order marker views are drawn. You can do this by calling setChildrenDrawingOrderEnabled(true) and overriding getChildDrawingOrder(int childCount, int i) on any ViewGroup.

    To make this work in MarkerViewManager, we need to maintain a drawing order based on a float. Current thinking is to use the zIndex keyset value of Map<MarkerView, View> for this. With this we also have a parity with Marker from Google. If this solution works out we might need to look into not merging #5238 (comment) since this will be all inclusive solution and could work for all MarkerViews at the same time.

  16. tobrun commented on Aug 26, 2016

    @tobrun
    MemberAuthor

    I got the sorting implemented with a compareTo:

                @Override
                public int compare(MarkerView lhs, MarkerView rhs) {
                    int compare = Float.compare(lhs.getzIndex(), rhs.getzIndex());
                    if (compare == 0) {
                        return Long.valueOf(lhs.getId()).compareTo(rhs.getId());
                    }else{
                        return compare;
                    }
                }

    This will sort the keys of a TreeMap based on MarkerView zIndex value, if they are equal we compare using id instead. The last remaining tasks is making actually changing the drawing order for this we need to map to original drawing order on our ordered keys.

    update:
    Had to change compareTo to match the compareTo from Annotation also simplified the code.

        @Override
        public int compareTo(@NonNull Annotation annotation) {
            if (annotation instanceof MarkerView) {
                MarkerView other = (MarkerView) annotation;
                if (zIndex < other.getzIndex()) {
                    return 1;
                } else if (zIndex > other.getzIndex()) {
                    return -1;
                }
            }
            return super.compareTo(annotation);
        }
  17. zugaldia commented on Aug 29, 2016

    @zugaldia
    Member

    @tobrun is zIndex == other.getzIndex() a possibility?

  18. tobrun commented on Aug 29, 2016

    @tobrun
    MemberAuthor

    yes, in that case it is calling super.compareTo(annotation) which falls back on the Annotation compareTo which uses comparison on id. In other words, in case we have the same zIndex, we will layer those MarkerViews based on when it was added to the map.

  19. zugaldia commented on Aug 29, 2016

    @zugaldia
    Member

    @tobrun 👍

  20. removed their assignment
    on Sep 6, 2016
  21. altafrm3d commented on Jan 27, 2017

    @altafrm3d

    Is there something to give Z values to Polylines/Polygons to defines in which order should they show up on MapView? If not, does this ticket cover this feature request?

  22. hanspeide commented on Apr 23, 2017

    @hanspeide

    From what I understand this issue tracks z ordering for MarkerViews. Is z ordering for Markers being tracked anywhere?

  23. zugaldia commented on Apr 24, 2017

    @zugaldia
    Member

    @hanspeide This is a good ticket to read about ordering of annotations, particularly this comment: #1728 (comment).

    Runtime styling is now available in the latest version of the SDK and can help with some of the use cases described in this ticket. This activity, for example, shows how to add a layer below another layer using mapboxMap.addLayerBelow().

  24. hanspeide commented on Apr 26, 2017

    @hanspeide

    @zugaldia Do layers support adding Markers? If not, what is the alternative?

  25. zugaldia commented on Apr 26, 2017

    @zugaldia
    Member

    @hanspeide You can add a symbol layer with a marker source. There's a SymbolLayerActivity example in the demo app that shows how to do it. It looks like this:

    SymbolLayerActivity

    In general, the demo app is a great resource to get a good sense of what's possible using the current APIs (and it's completely open source).

  26. tobrun commented on Sep 27, 2017

    @tobrun
    MemberAuthor

    MarkerView is going to be deprecated with #9782. We are no longer maintaining this API and will remove it in future versions of the SDK. As noted in the deprecation message. We are advising users to leverage SymbolLayer instead (you can use the sample code in #9782 to convert Android SDK views to an Image to be used as a Symbol). While we no longer maintain the API we are happy to accept any PRs on it.

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

Metadata

Metadata

Assignees

Labels

Androidannotationsfeature

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions