我在用 GMSMaker,我的 maker 的图标很好,但是我不能设置 groundAnchor
,它根本不显示,我不知道为什么?
一切都很好,只是 groundAnchor
有人可以帮助我吗?
let marker = GMSMarker(position: position)
let icon = UIImage(named: "m\(index+1).png")
let scaled = self.scaleImage(icon!, scale: 0.5)
marker.title = placeType.name
marker.icon = scaled
marker.appearAnimation = kGMSMarkerAnimationPop
marker.groundAnchor = CGPointMake(0.5, 1)
marker.map = self.mMapView
最佳答案
groundAnchor 是相对于 GSMarker
中图标中心的偏移量,其中 CGPoint(0.5,0.5)
是对应于 GSMarker< 中心的默认值
,因此在您的示例中,您正在将偏移量调整到 width
的中心和整个 height
Google Maps SDK for iOS 文档
The ground anchor specifies the point in the icon image that is anchored to the marker's position on the Earth's surface. This point is specified within the continuous space [0.0, 1.0] x [0.0, 1.0], where (0,0) is the top-left corner of the image, and (1,1) is the bottom-right corner.
此属性不会向您的 GSMarker
显示任何其他信息
希望对你有帮助
关于ios - GMSMarker 不显示 GroundAnchor iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41228867/