在GMSMarker背后发送CALayer
问题描述:
谷歌地图中的标记似乎是位于GMSMapView图层上的叠加层。在GMSMarker背后发送CALayer
我有一个额外的图层,我希望它在GMSMarker背后,但无论我做什么,图层都保持在最前面。
///creating the marker
var locValue:CLLocationCoordinate2D = manager.location!.coordinate
var currentLocationMarker = GMSMarker(position: locValue)
currentLocationMarker.icon = UIImage(named: "loc_now")
currentLocationMarker.map = viewMap //(GMSMapView)
///creating the layer and positioning it
var newlayer = CALayer()
newlayer.backgroundColor = UIColor.red.cgColor
newlayer.frame = CGRect(x: 100, y: 100, width: 100, height: 100)
newlayer.position.x = (currentLocationMarker.map?.layer.position.x)!
newlayer.position.y = ((currentLocationMarker.map?.layer.position.y)!-20)
viewMap.layer.insertSublayer(newlayer, at: 1) //no matter what it always sits on top of the marker
答
如何viewMap.layer.insertSublayer(newlayer, at: 0)
可能的工作。我真的不知道迅速,但给它一个
我试过,0不可见,1不可见,2是可见的,在一切。 –