I want to open google map naviagation directly through googgle map App.
currenly i am using the code below
NSURL *testURL = [NSURL URLWithString:#"comgooglemaps-x-callback://"];
if ([[UIApplication sharedApplication] canOpenURL:testURL]) {
NSString *direction=[NSString stringWithFormat:#"comgooglemaps-x-callback://?saddr=%#,%#&daddr=%#,%#&x-success=sourceapp://?resume=true&x-source=AirApp", #"18.9750", #"72.8258", #"23.0300",#"72.5800"];
NSURL *directionsURL = [NSURL URLWithString:direction];
[[UIApplication sharedApplication] openURL:directionsURL];
}
else {
showAlert(AlertTitle, #"You don't have GoogleMaps App on this device. Please install it.");
//NSLog(#"Can't use comgooglemaps-x-callback:// on this device.");
}
}
But that is showing only direction and after that i need to click on navigation button in the App , is there is any way so that i can open google map navigation
directly.
Related
How I show built in navigation options on google map iOS source and destination and navigation with voice or I have to implement google map api for this?
you can use the following code; it'll appear the selected location with drop annotation; and from google app you can navigate
https://developers.google.com/maps/documentation/ios-sdk/urlscheme
if ([[UIApplication sharedApplication] canOpenURL:[NSURL
URLWithString:#"comgooglemaps://"]])
{
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:#"comgooglemaps://?center=%f,%f&q=%f,%f",mosqueLocation.latitude,mosqueLocation.longitude, mosqueLocation.latitude,mosqueLocation.longitude]];
[[UIApplication sharedApplication] openURL:url];
} else {
NSLog(#"Can't use comgooglemaps://");
}
I'm trying to open Google Maps app when I click on embed google maps sdk in Xcode. Please help me in order to find the solution?
Add one key in .plist file "LSApplicationQueriesSchemes" and mention one item "comgooglemaps" in that.
Then try this code.
if ([[UIApplication sharedApplication] canOpenURL: [NSURL URLWithString:#"comgooglemaps:"]]) {
NSURL *directionsURL = [NSURL URLWithString:#"comgooglemaps://"];
[[UIApplication sharedApplication] openURL:directionsURL];
}
else{
[[UIApplication sharedApplication] openURL:[NSURL
URLWithString:#"https://itunes.apple.com/us/app/google-maps/id585027354?mt=8"]];
}
I can open Google maps app using [NSURL URLWithString:#"comgooglemaps://...."]
But how to open Navigation mode?
The navigation mode is explained here, "Add navigation to your app" : https://developers.google.com/maps/documentation/ios-sdk/urlscheme
Try this code :
NSURL *testURL = [NSURL URLWithString:#"comgooglemaps-x-callback://"];
if ([[UIApplication sharedApplication] canOpenURL:testURL]) {
NSString *directionsRequest = #"comgooglemaps-x-callback://" + #"?daddr=John+F.+Kennedy+International+Airport,+Van+Wyck+Expressway,+Jamaica,+New+York" + #"&x-success=sourceapp://?resume=true&x-source=AirApp";
NSURL *directionsURL = [NSURL URLWithString:directionsRequest];
[[UIApplication sharedApplication] openURL:directionsURL];
}
Is it possible to force through your application that it will open the web link in safari only not in native app like facebook, twitter or web view etc.
So far i searched found only this code that is used for opening the link
NSURL *url = [NSURL URLWithString:#"www.facebook.com"];
[[UIApplication sharedApplication] openURL:url];
But what can we paste in else there below?
if ([[UIApplication sharedApplication] canOpenURL:nsurl]){
[[UIApplication sharedApplication] openURL:nsurl];
}
else {
//Open the url as usual, but how?
}
Use http://facebook.com/ instead of www.facebook.com
this will force a link to open in Safari instead of native app*
NSURL *myURL = [NSURL URLWithString:#"http://facebook.com/"];
if ([[UIApplication sharedApplication] canOpenURL:myURL]) {
[[UIApplication sharedApplication] openURL:myURL];
}
You can use a webView to open any link of your choice.
I'm trying to launch Google Maps iOS Application in my Application by doing this :
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = #"Google Map";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:
#"comgooglemaps://?center=40.765819,-73.975866&zoom=14&views=traffic"]];
}
However, the app does not launch Google Maps iOS at all. I do have Google Maps iOS installed.
What I am missing over here?
Can somebody help me out?
Thanks.
Try this instead
CLLocationCoordinate2D coordinate = COORDINATE;
// Open Google Maps application
if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:#"comgooglemaps://"]]) {
NSString *daddr = [NSString stringWithFormat:#"%g,%g",coordinate.latitude, coordinate.longitude];
NSString *urlString = nil;
BOOL showQuery = YES;
if (showQuery) {
// Query
urlString = [NSString stringWithFormat:#"comgooglemaps://?q=%#",daddr];
} else {
// Directions
urlString = [NSString stringWithFormat:#"comgooglemaps://?saddr=&daddr=%#", daddr];
}
NSURL *url = [NSURL URLWithString:urlString];
[[UIApplication sharedApplication] openURL:url];
}
You'll need to include comgooglemaps url scheme to your project Info.plist. I recommend checking out Localide. It helps you open Google Maps, Waze, Apple Maps, Transit App, Citymapper, and Navigon very easily.