Monday, 3 March 2014

Setting Region and Annotation in Map View for a coordinate

//Create a coordianate
    CLLocationCoordinate2D coordinate= CLLocationCoordinate2DMake(37.785834,-122.406417);
    //Set region for with the coordiante
    MKCoordinateRegion region =MKCoordinateRegionMakeWithDistance(coordinate, 800, 800);
    [self.mapView setRegion:[self.mapView regionThatFits:region] animated:YES];
    //add point annotaion to map view
    MKPointAnnotation *point=[[MKPointAnnotation alloc] init];
    point.coordinate=coordinate;
    point.title=@"hai I am here!!";
    point.subtitle=@"hey how are you?";
    [self.mapView addAnnotation:point];

No comments:

Post a Comment