Putting a CLPlacemark on Map in iOS 5

后端 未结 3 1868
执念已碎
执念已碎 2021-02-14 10:18

In iOS 5, there is a new way to forward geocode address (converting address like 1 Infinite Loop, CA, USA to lat/lang address). More info on this is here.

Has anybody t

3条回答
  •  闹比i
    闹比i (楼主)
    2021-02-14 11:03

    A CLPlacemark doesn't implement the MKAnnotation protocol so you still have to create your own annotation class or you can use MKPointAnnotation. The coordinates of the placemark are in its location property.

    For example:

    MKPointAnnotation *pa = [[MKPointAnnotation alloc] init];
    pa.coordinate = placemark.location.coordinate;
    pa.title = ABCreateStringWithAddressDictionary(placemark.addressDictionary, YES);
    [mapView addAnnotation:pa];
    [pa release];  //remove if using ARC
    

    You can set the title to anything you want from the placemark but one possibility, as shown in the example, is to use the Address Book UI framework to generate an address string from the address dictionary provided by the placemark.

提交回复
热议问题