【问题标题】:how to display Single Location on mapview in iOs?如何在 iOs 的地图视图上显示单个位置?
【发布时间】:2016-07-17 17:57:02
【问题描述】:

如何在 mapview 上显示带有经度和纬度坐标的单个位置(不是我当前的位置!)?

我只想显示带有这些随机坐标的单个位置 - 当这些坐标发生变化时,必须删除地图视图上的旧位置并用新坐标替换?我该怎么做?

【问题讨论】:

  • 你试过什么?向MKMapView 添加注解并删除它非常简单。

标签: ios swift location mkmapview


【解决方案1】:

添加注释:

let annotation = MKPointAnnotation()
annotation.title = title
annotation.coordinate = coordinate
mapView.addAnnotation(annotation)

然后您可以使用removeAnnotation 将其移除并添加新注释,或者您可以将其移动到新坐标的动画:

UIView.animateWithDuration(1.0) {
    annotation.coordinate = newCoordinate
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多