ios - GMSMarker 不显示 GroundAnchor iOS

标签 ios swift google-maps maps google-maps-markers

我在用 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/

相关文章:

javascript - 使用 Google Autocomplete API 根据位置名称获取经纬度

ios - 有人可以看看我的代码并告诉我为什么我的数组 (AllNews) 在单元格内是空的吗

ios - 有没有更简单的方法来处理 ios 应用程序中的许多数据更改?

iOS WeMo SDK 架构问题

macos - setResourceValue NSURLTagNamesKey 错误

ios - 持久化 Collection View 单元格选择

ios - TableViewcell 内的按钮缺少警告尾随约束的正确方法是什么

swift - 个人资料图片和上传按钮 : firebase : swift 4. 0:jpeg 转换为数据时出现问题

android - Google FusedLocationApi API 调用 onConnectionSuspended 的时间太多,我无法获取 GPS 位置

javascript - 将图像放在 Google map 上