ios - 中心的 GMSMarker 图标 (iOS)

标签 ios google-maps google-maps-markers center gmsmapview

我刚刚从 Apple Maps 切换到 Google Maps。我似乎找不到答案的一个问题是如何使 GMSMarker 的图标从中心开始而不是从图像底部开始。

我的意思的一个例子是当前位置点图标以它要表达的坐标为中心开始。然而 GMSMarkers 图标从图标的底部开始。

最佳答案

您可以使用属性 groundAnchor 更改标记图标的起始位置。

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.

示例:

The below example rotates the marker 90°. Setting the groundAnchor property to 0.5,0.5 causes the marker to be rotated around its center, instead of its base.

CLLocationCoordinate2D position = CLLocationCoordinate2DMake(51.5, -0.127);
CLLocationDegrees degrees = 90;
GMSMarker *london = [GMSMarker markerWithPosition:position];
london.groundAnchor = CGPointMake(0.5, 0.5);
london.rotation = degrees;
london.map = mapView_;

关于ios - 中心的 GMSMarker 图标 (iOS),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28955976/

相关文章:

ios - UIview.hidden 不会消失,而是隐藏在另一个 View 后面

ios - 如何以编程方式更改 UITableViewCell 上的约束?

android - Android 谷歌地图中的线条和绘图绘制顺序

javascript - SOAP - Google map 和 Javascript - 连接到网络服务

IOS Swift Google map 截断标题

javascript - Angular 6 从谷歌地图中删除所有标记

javascript - 在将 fitBounds() 与 Google Maps API V3 结合使用后使用 setZoom()

iphone - Coreplot图沿y轴的填充颜色

ios - 在 SwiftUI 中向按钮添加文本和图像

android - 从 parse.com 检索和使用用户信息