Archive: November, 2011

Launch Maps App from PhoneGap

If you need to launch the maps application from a PhoneGap application you can do so by editing your AppDelegate.m file with the code below. If you’re not using ChildBrowser you can comment out the else condition.

Archived here for my own sake from the PhoneGap Google Group.

- (BOOL)webView:(UIWebView *)theWebView shouldStartLoadWithRequest: (NSURLRequest *)request navigationType: (UIWebViewNavigationType)navigationType { NSURL *url = [request URL];

if (![[url scheme] hasPrefix:@"http"] ||
    [[url scheme] isEqualToString:@"gap"] || 
    [url isFileURL] )
{ 
    return [super webView:theWebView shouldStartLoadWithRequest:request 
        navigationType:navigationType]; 
}
else
{ 
    ChildBrowserViewController* childBrowser = [[ChildBrowserViewController alloc] 
                                                initWithScale:FALSE]; 
    [super.viewController presentModalViewController:childBrowser animated:YES ]; 
    [childBrowser loadURL:[url description]]; 
    [childBrowser release]; 
    return NO; 
}

}

back to the top