Get Path & Navigation in Google Map
Write Code in info.plist :-
:- For Get Current Location permit :-
<key>NSLocationWhenInUseUsageDescription</key>
<string>This Application requires location service to work</string>
:- For Google Map Application :-
<key>LSApplicationQueriesSchemes</key>
<array>
<string>comgooglemaps</string>
</array>
Write Method in Class :-
-(void)GetNavigation
{
float lat_dest1 = [strLatitude floatValue];
float lng_dest1 = [strLongitude floatValue];
if ([[UIApplication sharedApplication] canOpenURL:[NSURLURLWithString:@"comgooglemaps://"]])
{
CLLocationCoordinate2D start = { (locationmanager.location.coordinate.latitude), (locationmanager.location.coordinate.longitude) };
CLLocationCoordinate2D end = { (lat_dest1), (lng_dest1) };
NSString *googleMapsURLString = [NSStringstringWithFormat:@"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:[NSURLURLWithString:googleMapsURLString]];
}
else
{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Sorry !!"message:@"First Install Google map" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* yesButton = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
//Handel your yes please button action here
}];
[alert addAction:yesButton];
[self presentViewController:alert animated:YES completion:nil];
}
}
No comments:
Post a Comment