来自中心的GMSMarker图标(iOS) [英] GMSMarker icon from center (iOS)
问题描述
我刚刚从Apple地图切换到Google地图。我似乎无法找到答案的一个问题是,如何让GMSMarker的图标从中心开始,而不是从图像的底部开始。
我的意思是,当前位置的点图标开始位于要表达的坐标中心。但是GMSMarkers图标从图标的底部开始。
您可以使用属性 适用于iOS文档的Google地图SDK : 地锚将图标图像中指向 示例: 以下示例将标记旋转90°。将groundAnchor I just switched from Apple Maps to Google Maps. An issue that I can't seem to find an answer to is how do you make the icon for a GMSMarker to start from the center rather then from the bottom of the image. An example of what I mean is the current location dot icon starts centered at the coordinates it is meant to express. However GMSMarkers icons start from the bottom of the icon. You can change the start position of your marker icon with the property Google Maps SDK for iOS documentation: 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. Example: 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.
这篇关于来自中心的GMSMarker图标(iOS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! groundAnchor $ c $更改标记图标的起始位置
$ b
的点固定到地球表面上的标记位置。此点
在连续空间[0.0,1.0] x [0.0,1.0],
中指定,其中(0,0)是图像的左上角,而(1,1)是
的右下角。
属性设置为0.5,0.5会导致标记围绕其中心旋转
而不是其基点。
CLLocationCoordinate2D position = CLLocationCoordinate2DMake(51.5,-0.127);
CLLocationDegrees degree = 90;
GMSMarker * london = [GMSMarker markerWithPosition:position];
london.groundAnchor = CGPointMake(0.5,0.5);
london.rotation =度;
london.map = mapView_;
groundAnchor
.
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_;