You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
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
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).
@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.
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.
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.
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.
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.
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.
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?
@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().
@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:
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).
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.
Activity
tobrun commentedon Jun 6, 2016
Instead of calling it layers, the term
Overlayis 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).tobrun commentedon Jun 6, 2016
If you currently pan an MarkerView towards the CompassView you will see that the MarkerView goes over the CompassView instead of going underneath.
zugaldia commentedon Jun 8, 2016
Related: #5285 (Android equivalent of #991).
tobrun commentedon Jun 14, 2016
@ivovandongen has been picking related items up in #5298 & #5294.
We need to validate if those fixes fulfil the requirements of this ticket.
zugaldia commentedon Jun 14, 2016
@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.
tobrun commentedon Jun 16, 2016
Moving this of the milestone, what we want for 4.1.0 is in place.
TBD what we want to add in future releases.
zugaldia commentedon Jun 16, 2016
👍
tobrun commentedon Jun 23, 2016
A user reached out in #5451 requesting the possibility to assign a MarkerView to a layer and manipulate layers completely (eg. hide a layer).
20 remaining items
tobrun commentedon Aug 24, 2016
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.
zugaldia commentedon Aug 24, 2016
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.
tobrun commentedon Aug 26, 2016
Been testing out the concept of changing the order marker views are drawn. You can do this by calling
setChildrenDrawingOrderEnabled(true)and overridinggetChildDrawingOrder(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.tobrun commentedon Aug 26, 2016
I got the sorting implemented with a
compareTo: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.
zugaldia commentedon Aug 29, 2016
@tobrun is
zIndex == other.getzIndex()a possibility?tobrun commentedon Aug 29, 2016
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.zugaldia commentedon Aug 29, 2016
@tobrun 👍
altafrm3d commentedon Jan 27, 2017
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?
hanspeide commentedon Apr 23, 2017
From what I understand this issue tracks z ordering for
MarkerViews. Is z ordering forMarkers being tracked anywhere?zugaldia commentedon Apr 24, 2017
@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().hanspeide commentedon Apr 26, 2017
@zugaldia Do layers support adding
Markers? If not, what is the alternative?zugaldia commentedon Apr 26, 2017
@hanspeide You can add a symbol layer with a marker source. There's a
SymbolLayerActivityexample in the demo app that shows how to do it. It looks like this: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).
tobrun commentedon Sep 27, 2017
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.