3

On the new iOS 10 release, I noticed that my custom GMSMarker views were rendering differently then they used to. I am currently on Google Maps 2.10 which is the latest.

My Setup

First, I create a GMSMarker in a very basic way just for this example.

GMSMarker *marker = [GMSMarker markerWithPosition:initialPosition];
marker.appearAnimation = kGMSMarkerAnimationNone;
marker.tracksViewChanges = NO;

marker.iconView = markerView;
marker.groundAnchor = CGPointMake(0.5, 0.5);
marker.map = self.mapView;

In the above code I am creating the GMSMarker and assigning it a markerView which is a custom UIView subclass that I have written. That implementation is below and is called GLMarkerView. Switching languages and it will be in Swift 3.0.

@objc class GLMarkerView: UIView {
    init(store: GLStore?) {
        let circleFrame = CGRect(x: 0, y: 0, width: 40.0, height: 40.0)
        super.init(frame: circleFrame)

        backgroundColor = UIColor.red.withAlphaComponent(0.4)
        layer.cornerRadius = 20.0
        isOpaque = false
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}

The Results

So everything above is a very simple layout to make sure that I was not doing anything specific that was causing this problem. Based on the code above, I should see the markers on the GMSMapView and they should be translucent red circles. On iOS 9 and below this works perfectly. And I get the following result:

What the Map looks like on iOS 9

However when I run the exact same code on iOS 10, I get the following view:

What the Map looks like on iOS 10

The Problem

For some reason there is this darker background added to the rendering that I have no idea where it is coming from. Ran view debugging, changed the UIView to set isOpaque = false. Tried a wide array of things to get this to render correctly.

One thing I noticed is that it is not just transparency that this effects. If I run the same code with a white background, the circles have strange anti-aliasing problems with their borders.

If anyone has seen this issue and knows of a way to fix it, any help would be more than appreciated. If you need any more information on this problem or have any questions about the implementation, please feel free to ask and I will respond as quickly as I can. Thanks in advance!

  • fwiw, I'm seeing similar issues with a custom pin view on iOS 10. – Eric Oct 24 '16 at 22:22
  • @Eric I submitted a bug to Google the other day, and then just responded that it is an Apple Issue. Here is a link to the Issue: https://code.google.com/p/gmaps-api-issues/issues/detail?id=10735 – Jackson Taylor Oct 24 '16 at 22:24
  • Ooh, awesome, thanks for the link! – Eric Oct 24 '16 at 22:45

0 Answers0