Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6994599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:54:47+00:00 2026-05-27T19:54:47+00:00

I want to design a dynamic pin annotation on Google map in iPhone such

  • 0

I want to design a dynamic pin annotation on Google map in iPhone such that user can drag the pin by taping on it and place this pin on Google maps to set the location of its choice.
After user puts the pin I want to get the location coordinates and location name corresponding to that pin.
Any suggestion how to develop this in iPhone.
Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:54:47+00:00Added an answer on May 27, 2026 at 7:54 pm

    In your view controller you have to implement methods from MKMapViewDelegate protocol and LongPressGestureAware (which I created) for dropping the pin on the map when the user taps and hold on the screen.

    Your annotation should implement MKAnnotation and MKReverseGeocoderDelegate protocols.

    I paste some of my code which can help you:

    SimpleMapAnnotationViewController.h:

    @interface SimpleMapAnnotationViewController : TTViewController<LongPressGestureAware, MKMapViewDelegate> {
        SimpleMapAnnotation *_dropPin;
        MKPinAnnotationView *_pinView;
    }
    

    SimpleMapAnnotationViewController.m :

    #pragma mark -
    #pragma mark LongPressGestureAware
    
    -(void) initLongPressGestureRecognizer {
        UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGesture:)];
        [self.map addGestureRecognizer:longPressGesture];
        [longPressGesture release];
    }
    
    -(void)handleLongPressGesture:(UIGestureRecognizer*)sender {
    
        if([sender isMemberOfClass:[UILongPressGestureRecognizer class]] && (sender.state == UIGestureRecognizerStateEnded || sender.state == UIGestureRecognizerStateBegan)) {
        [self.map removeGestureRecognizer:sender]; //avoid multiple pins to appear when holding on the screen
        } 
        CGPoint point = [sender locationInView:self.map];
        CLLocationCoordinate2D theCoordinate = [self.map convertPoint:point toCoordinateFromView:self.map];
        self.dropPin = [[[SimpleMapAnnotation alloc] initWithCoordinate:theCoordinate] autorelease];
        [self.map addAnnotation:self.dropPin];
        [self performSelector:@selector(selectInitialAnnotation) withObject:nil afterDelay:0.5];
    }
    
    -(void)selectInitialAnnotation {
        [self.map selectAnnotation:[self.map.annotations objectAtIndex:0] animated:YES];
    }
    
    #pragma mark -
    #pragma mark MKMapViewDelegate
    
    - (MKAnnotationView *) mapView: (MKMapView *) mapView viewForAnnotation: (id<MKAnnotation>) annotation {
        if (annotation == self.map.userLocation){
            return nil; //default to blue dot
        }
        MKPinAnnotationView *pin = (MKPinAnnotationView *) [mapView dequeueReusableAnnotationViewWithIdentifier: @"annotation_ID"];
        if (pin == nil) {
            pin = [[[MKPinAnnotationView alloc] initWithAnnotation: annotation reuseIdentifier: @"annotation_ID"] autorelease];
        } else {
            pin.annotation = annotation;
        }
    
        pin.canShowCallout = YES;
        pin.draggable = YES;
        pin.animatesDrop = YES;
        pin.pinColor = MKPinAnnotationColorGreen;
    
        self.pinView = pin;
        self.dropPin.pinView = self.pinView;    
        return pin;
    }
    
    
    - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState {
    //NSArray *annotations = self.map.annotations;
    if (oldState == MKAnnotationViewDragStateDragging) {
        SimpleMapAnnotation *annotation = (SimpleMapAnnotation *)annotationView.annotation;
        [annotation updateSubtitle];    
    }
    if(newState == MKAnnotationViewDragStateEnding) {
        NSLog(@"drag finish");
    }
    }
    

    SimpleMapAnnotation.h

    @interface SimpleMapAnnotation : NSObject <MKAnnotation, MKReverseGeocoderDelegate> {
        CLLocationCoordinate2D _coordinate;
        NSString *_title;
        NSString *_subtitle;
        MKPinAnnotationView *_pinView; 
    }
    

    SimpleMapAnnotation.m

    - (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate {  
        self.coordinate = coordinate;
        MKReverseGeocoder *geoCoder = [[MKReverseGeocoder alloc] initWithCoordinate:self.coordinate];
        geoCoder.delegate = self;
        [geoCoder start];
        self.subtitle = [NSString   stringWithFormat:@"%f %f", self.coordinate.latitude, self.coordinate.longitude]; 
    return self;
    }
    
    #pragma mark -
    #pragma mark MKReverseGeocoderDelegate
    
    // this delegate is called when the reverseGeocoder finds a placemark
    - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
    {
        MKPlacemark * myPlacemark = placemark;
        NSString *address = [myPlacemark.addressDictionary objectForKey:(NSString*) kABPersonAddressStreetKey];
        self.title = address;
    }
    
    // this delegate method is called if an error occurs in locating your current location
    - (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error 
    {
        NSLog(@"locationManager:%@ didFailWithError:%@", manager, error);
    }
    
    // this delegate is called when the reversegeocoder fails to find a placemark
    - (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error
    {
         //invalid place
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have a problem that, I want design a Scroller which contains a dynamic
That's my question, I want design all the interface of my application within an
I want to design a c# program which can run program a 3rd exe
I know it's a weird question but I want to design a program that
(edited) I want to display a dynamic list of JPanels that hold textfield that
I created a flowlayout panel in design view and I want to place in
I am doing some game design, and decided that I want a data centric
I want to make a dynamic filling list that fill the screen what ever
I have a dynamic user control that instantiates various bars and labels dynamically based
I want design my startup screen with progress bar. But I don't how to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.