中心的GMSMarker图标(iOS)

我刚刚从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_;

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...