Google Navigation in MapView of Iphone using Custom Callout pin

325 views Asked by At

Greetings,

            I have a very weird but interesting requirement.

What I need is, I have a set of geoPoints stored inside my database. What I have done so far is , successfully retrieved the lat. long pair and displayed it on the MapView using the default pin points. Every annotation has a unique title and subtitle derived from the database.

What my requirement is, when I click a particular pin, I wish to display an AlertView. In that AlertView there will be two buttons, 1)Get Directions 2)Dismiss.

1)Get Directions.

When I click on GetDirections, it should fetch the respective Latitude and Longitude and I have the current Latitude and Current Longitude. Then, it should open a WebView and do this

- (void)getDirections {
    CLLocationCoordinate2D start = { (startLat), (startLong) };
    CLLocationCoordinate2D end = { (EndLat), (EndLong) };

    NSString *googleMapsURLString = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f", start.latitude, start.longitude, end.latitude, end.longitude];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURLString]];

}

I am planning to display this WebView in a different view using ModalViewController with a back button, so that I can navigate back to my Mapview.

Please let me know if this is practically /programatically possible.

0

There are 0 answers