If we want to display the annotation point on any coordinates in MKMapView use the following functions-
By using the annotation anyone can easily recognize the location.We can also set the Title here which will show when user click on that annotation.
-(void)getPinOnMap{
CLLocationCoordinate2D businessLocation;
//set value of latitude and longitude
businessLocation.latitude = [latitude doubleValue];
businessLocation.longitude= [longitude doubleValue];
MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
[annotation setCoordinate:businessLocation];
[annotation setTitle:[NSString stringWithFormat:@"Location Title Here"]]; //You can set the subtitle too
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(businessLocation, 0.5*OFFSET_ZOOM, 0.5*OFFSET_ZOOM);
[self.mapView setRegion:viewRegion animated:YES];
[self.mapView addAnnotation:annotation];
}
Here OFFSET_ZOOM is the constant and mapView is the property of MKMapView.
0 Comment(s)