我正在尝试创建一个包含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)
这是我遇到的问题的屏幕截图: 标记位于地图的左上角