简体   繁体   English

在MKMapView上绘制CLLocation / CLLocationCoordinate2D

[英]Plotting CLLocation/CLLocationCoordinate2D on a MKMapView

I am obtaining the users location via Parse and the object is returned as a PFGeoPoint. 我正在通过Parse获取用户位置,并且该对象作为PFGeoPoint返回。 I have converted it to a CLLocation / CLLocationCoordinate2D by doing so: 我通过这样做将其转换为CLLocation / CLLocationCoordinate2D:

CLLocation *loc = [[CLLocation alloc] initWithLatitude:self.geoPoint.latitude longitude:self.geoPoint.longitude];
    CLLocationCoordinate2D coordinate = [loc coordinate];

Question is to add an annotation on a mapView it appears I need a MKPointAnnotation. 问题是在mapView上添加注释,它似乎需要MKPointAnnotation。 How would I go about converting what I have to be able to add it to my mapView? 我将如何转换必须将其添加到mapView的内容?

You can create a MKPointAnnotation for a specific location this way: 您可以通过以下方式为特定位置创建MKPointAnnotation:

MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
annotation.coordinate = coordinate;

This annotation can then be added to the map view. 然后可以将此注释添加到地图视图。

[mapView addAnnotation:annotation];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM