更改Android中Maps V2的地图标记的z-index(z-order)

更改Android中Maps V2的地图标记的z-index(z-order),第1张

概述我的地图上显示的几个标记是彼此接近的,甚至是彼此顶部的.我需要一个特定的标记总是在上面.无论如何将标记添加到地图首先或最后,它通常最终被放置在一些标记之后.由于某些神秘的原因,Google Maps决定了这一点.它需要使用Google Maps for Android V2. 2016年6月27日,Android Maps API v2版本v9.2.0现在支持z-index – 请参阅 https 我的地图上显示的几个标记是彼此接近的,甚至是彼此顶部的.我需要一个特定的标记总是在上面.无论如何将标记添加到地图首先或最后,它通常最终被放置在一些标记之后.由于某些神秘的原因,Google Maps决定了这一点.它需要使用Google Maps for Android V2.解决方法 2016年6月27日,AndroID Maps API v2版本v9.2.0现在支持z-index – 请参阅 https://developers.google.com/maps/documentation/android-api/releases#june_27_2016发布.

因此,请确保您的地图/播放服务版本在build.gradle中设置为v9.2.0:

compile 'com.Google.androID.gms:play-services-maps:9.2.0'

z-index文档如下(从https://developers.google.com/maps/documentation/android-api/marker#marker_z-index):

The z-index specifIEs the stack order of this marker,relative to other markers on the map. A marker with a high z-index is drawn on top of markers with lower z-indexes. The default z-index value is 0.

Markers are always drawn above tile layers and other non-marker overlays (ground overlays,polylines,polygons,and other shapes) regardless of the z-index of the other overlays. Markers are effectively consIDered to be in a separate z-index group compared to other overlays.

将标记添加到地图时可以设置索引:

map.addMarker(new MarkerOptions()    .position(new LatLng(10,10))    .Title("Marker z1")    .zIndex(1.0f));

…或者在创建标记后使用Marker.setZIndex().

关于z-index对点击事件的影响的更多文档低于(从@L_403_3@):

When a user clicks on a cluster of markers,the click event is triggered for the marker with the highest z-index. At most one event is triggered per click. In other words,the click is not passed down to the markers or other overlays with lower z-index values. Clicking on a cluster of markers causes subsequent clicks to cycle through the cluster,selecting each in turn. The order of the cycle first prioritises z-index,then proximity to the click point. If the user clicks outsIDe the proximity of the cluster,the API recalculates the cluster and resets the state of the click cycle so that it starts from the beginning. The click event falls through marker clusters to other shapes and overlays before restarting the cycle. Markers are effectively consIDered to be in a separate z-index group compared to other overlays or shapes (polylines,circles,and/or ground overlays),regardless of the z-index of the other overlays. If multiple markers,overlays or shapes are overlaID on top of each other,the click event is cycled through the cluster of markers first,then triggered for other clickable overlays or shapes,based on their z-index values.
总结

以上是内存溢出为你收集整理的更改Android中Maps V2的地图标记的z-index(z-order)全部内容,希望文章能够帮你解决更改Android中Maps V2的地图标记的z-index(z-order)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1132148.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存