osmdroid标记相互重叠,是否有像z-index这样的东西?

时间:2021-06-09 15:02:33

I have a osmdroid MapView with lots of markers that in many times overlap each other. Is there a way to bring selected marker to front with something like z-index?

我有一个osmdroid MapView,它有很多标记,在很多时候相互重叠。有没有办法将选定的标记带到像z-index这样的东西?

1 个解决方案

#1


5  

There is no z-index in osmdroid overlays, overlays are drawn from first to last => first is "behind", last is "in front". To push an overlay "in front", you have to change its relative position in the list of overlays.

osmdroid叠加层中没有z-index,从头到尾绘制叠加层=>第一个是“后面”,最后一个是“在前面”。要在“前面”按下叠加层,您必须在叠加列表中更改其相对位置。

If you are using OSMBonusPack, you could put your Markers in a FolderOverlay "myMarkersFolder". Then, to push an item "in front":

如果您使用的是OSMBonusPack,则可以将您的标记放在FolderOverlay“myMarkersFolder”中。然后,将项目“推到前面”:

AbstractList<Overlay> list = myMarkersFolder.getItems();
Overlay selectedMarker = list.remove(selectedMarkerIndex);
list.add(selectedMarker); //add at the end = in front

#1


5  

There is no z-index in osmdroid overlays, overlays are drawn from first to last => first is "behind", last is "in front". To push an overlay "in front", you have to change its relative position in the list of overlays.

osmdroid叠加层中没有z-index,从头到尾绘制叠加层=>第一个是“后面”,最后一个是“在前面”。要在“前面”按下叠加层,您必须在叠加列表中更改其相对位置。

If you are using OSMBonusPack, you could put your Markers in a FolderOverlay "myMarkersFolder". Then, to push an item "in front":

如果您使用的是OSMBonusPack,则可以将您的标记放在FolderOverlay“myMarkersFolder”中。然后,将项目“推到前面”:

AbstractList<Overlay> list = myMarkersFolder.getItems();
Overlay selectedMarker = list.remove(selectedMarkerIndex);
list.add(selectedMarker); //add at the end = in front