【问题标题】:how to convert MKMapPoint to CGPoint如何将 MKMapPoint 转换为 CGPoint
【发布时间】:2013-04-04 13:53:28
【问题描述】:

谁能解释如何将 MKMapPoint 转换为 CGPoint ?我需要在 UIView 上使用纬度和经度绘制路径。

【问题讨论】:

    标签: ios ipad ios5 mkmapview


    【解决方案1】:

    更新答案.......

    CGPoint newCenter = [self.mapView convertCoordinate:coordinates toPointToView:self.mapView];
    

    【讨论】:

    • 给 OP a -1 因为接受的答案不包含他们想要转换的类型。对于我们这些寻找原始问题答案的人来说没有帮助。
    • 请不要抄袭别人的答案。
    • @Matt 是的,但我之前发布了答案。它不是复制我只修改它。
    • @DharmbirSingh 因此您需要添加标记为更新的更改。否则,其他答案似乎复制了您的答案。
    【解决方案2】:

    接受的答案将 CLLocationCoordinate2D 转换为 CGPoint,这不是实际问题中所问的。对于那些在这里寻找完整答案的人来说,它是:

    MKMapPoint mapPoint = MKMapPointMake(22.1, 34.4);//example
    
    //first convert MKMapPoint to CLLocationCoordinate2D
    CLLocationCoordinate2D mapPointCoordinate = MKCoordinateForMapPoint(mapPoint);
    
    //second convert CLLocationCoordinate2D to CGPoint
    CGPoint pointAsCGPoint = [self.mapView convertCoordinate: mapPointCoordinate toPointToView: self.mapView];
    

    【讨论】:

    • 在任何人反对之前:接受的答案是在我的帖子之后编辑的,所以现在看来​​我的帖子是一个副本。相信upvotes :)
    猜你喜欢
    • 1970-01-01
    • 2011-05-12
    • 2017-07-29
    • 1970-01-01
    • 2011-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多