小编ste*_*eed的帖子

视图左上角的GMSMarker图标(iOS)

我正在尝试创建一个包含GMSMapView的UITableViewCell,其中GMSMaper在当前Position的中心。

问题是标记始终显示在当前位置的左上角,我不知道如何解决该问题。

我尝试按照以下步骤操作:使用UItableviewCell实现Google Map

这是我来自cellForRowAt的代码:

let locationCell = tableView.dequeueReusableCell(withIdentifier: "activityLocationCell") as! ActivityLocationCell

let latitude = CLLocationDegrees(activity.coordinates![0])
let longitude = CLLocationDegrees(activity.coordinates![1])
let position = CLLocationCoordinate2D(latitude: latitude, longitude: longitude)

locationCell.googleMapView.camera = GMSCameraPosition.camera(withTarget: position, zoom: 15)

let marker = GMSMarker(position: position)
marker.groundAnchor = CGPoint(x: 0.5, y: 0.5)
marker.map = locationCell.googleMapView

return locationCell
Run Code Online (Sandbox Code Playgroud)

这是我遇到的问题的屏幕截图: 标记位于地图的左上角

xcode google-maps ios google-maps-sdk-ios swift

5
推荐指数
1
解决办法
1508
查看次数

标签 统计

google-maps ×1

google-maps-sdk-ios ×1

ios ×1

swift ×1

xcode ×1