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_;
and this is the result:
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.
This is now supported via a zIndex
property added to the GMSOverlay
class in version 1.4.0. From the release notes:
Added a
zIndex
property on all overlays. Z-Indexes are calculated in two groups:GMSMarker
s and all other overlays.
Just set a high zIndex
on your marker to have it drawn on top of all others. As stated by the property documentation here:
Higher
zIndex
value overlays will be drawn on top of lowerzIndex
value tile layers and overlays.
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;