How do I add custom pins to the iPhone MapKit?

后端 未结 4 427
小鲜肉
小鲜肉 2020-12-05 19:25

I\'m testing out the MapKit framework on the iPhone and would really much like to switch the standard pin that displays a location to an image called \"location.png\".

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 20:14

    in.h file:
    float address_latitude;
    float address_longitude;
    
    - (void)viewDidLoad
    {
    
        CLLocationCoordinate2D coord1 =          CLLocationCoordinate2DMake(address_latitude,address_longitude);
        MKCoordinateSpan span = MKCoordinateSpanMake(0.0, 0.0);
        MKCoordinateRegion region1 = {coord1, span};
        MKPointAnnotation *annotation1 = [[MKPointAnnotation alloc] init];
        [annotation1 setTitle:@"Driver"];
        [annotation1 setCoordinate:coord1];
        [_map setRegion:region1];
        [_map addAnnotation:annotation1];
    
        }
    

提交回复
热议问题