×

MapKit地图当前位置及大头针

消耗积分:1 | 格式:rar | 大小:0.3 MB | 2017-09-26

分享资料个

  创建大头针、增加标记及覆盖物

  步骤-SB拖入地图视图-然后如下

  MapKit地图当前位置及大头针

  import MapKit

  class MapViewController: UIViewController,MKMapViewDelegate {

  @IBOutlet weak var mapView: MKMapView!

  override func viewDidLoad() {

  super.viewDidLoad()

  self.mapView.delegate = self

  //创建大头针

  let center = CLLocationCoordinate2DMake(23.114155, 113.318977)

  let span = MKCoordinateSpanMake(0.2, 0.2)

  self.mapView.region = MKCoordinateRegionMake(center, span)

  //向地址增加标记

  let annotation = MKPointAnnotation()

  annotation.coordinate = center

  annotation.title = “当前大约位置”

  annotation.subtitle = “”

  self.mapView.addAnnotation(annotation)

  //创建一个新的圆形覆盖物

  let overlay = MKCircle(centerCoordinate: center, radius: 5000)

  self.mapView.addOverlay(overlay)

  }

  //自定义大头针样式,默认是红色

  //func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -》 MKAnnotationView?

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

评论(0)
发评论

下载排行榜

全部0条评论

快来发表一下你的评论吧 !