Search code examples
iosios8google-maps-sdk-ios

How to add shadow to a GMSMarker?


I'm trying to add some shadow to the markers on my GMSMapView but configuring the shadow properties of GMSMarkerLayer does not appear to have any effect.

GMSMarker *marker = [[GMSMarker alloc] init];
[marker setMap:self.mapView];
marker.snippet = @"Description";
marker.title = @"Title";
marker.position = busData.location.coordinate;
marker.icon = [UIImage imageNamed:@"BusMarker"];
marker.layer.shadowOpacity = 0.7;
marker.layer.shadowOffset = CGSizeMake(0, 3);
marker.layer.shadowRadius = 5.0;
marker.layer.shadowColor = [UIColor blackColor].CGColor;

I'm setting the same properties I'd use on a CALayer object, as GMSMarkerLayer subclasses CALayer.

Am I doing something wrong or is this a bug? I'm using SDK version 1.10.0.


Solution

  • You can use iconView property and draw shadow inside that view (keeping it in bounds of iconView).