Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to display annotation on any Location in MKMapView

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 279
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: