在Google Maps SDK iOS中为所有其他标记设置标记 [英] Set a marker over all other markers in Google Maps SDK iOS

查看:157
本文介绍了在Google Maps SDK iOS中为所有其他标记设置标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试放置一个标记,但是当我这样做时,这个标记被放置在之前设置的一些标记之后(以及其他一些标记)。我想将它设置在所有标记上,但我没有找到任何属性(如z-index)来实现这一点。

I'm trying to place a marker, but when I do it, this marker is placed behind of some markers set before (and over some others as well). I want to set it over all the markers, but I didn't find any property (like z-index) to achieve this.

这是代码的一部分我设置的标记位于其他标记之后:

This is the part of the code where I set the marker that stays behind the others:

GMSMarker *marker = [[GMSMarker alloc] init];
marker.animated=YES;
marker.position = CLLocationCoordinate2DMake(lat, lon);
marker.map = mapView_;

这就是结果:

是否有任何属性或方法将绿色标记放在所有蓝色标记上?我正在使用Google Maps SDK版本1.3.0。

Is there any property or way to place the green marker over all blue markers? I'm using Google Maps SDK version 1.3.0.

推荐答案

现在通过 zIndex支持属性已添加到1.4.0版中的 GMSOverlay 类中。来自发行说明

This is now supported via a zIndex property added to the GMSOverlay class in version 1.4.0. From the release notes:


在所有叠加层上添加了 zIndex 属性。 Z-Indexes分为两组: GMSMarker s和所有其他叠加。

Added a zIndex property on all overlays. Z-Indexes are calculated in two groups: GMSMarkers and all other overlays.

只需在标记上设置一个高 zIndex 即可将其绘制在所有其他标记之上。如财产文档此处所述:

Just set a high zIndex on your marker to have it drawn on top of all others. As stated by the property documentation here:


更高的 zIndex 值叠加将在较低的 zIndex 值图块图层和叠加。

Higher zIndex value overlays will be drawn on top of lower zIndex value tile layers and overlays.

默认 zIndex 对于标记是 0 (至少在当前的SDK版本中 - 我没有看到它记录在案,但它很容易测试和确认),所以如果你没有为你的大多数标记设置 zIndex ,并且你要将其放在所有其他标记之上,你需要做的就是:

The default zIndex for a marker is 0 (at least in the current SDK version - I haven't seen it documented, but it's easy to test and confirm), so if you're not setting the zIndex for most of your markers and have one that you want to place above all the others, all you need to do is:

yourGmsMarker.zIndex = 1;

这篇关于在Google Maps SDK iOS中为所有其他标记设置标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆