with the following code i try to open a generated and saved KML file in Google Earth App.
Google Earth app opens but it do nothing.
When i send this file with email and open it with GE App it works fine. is there a way to open mml from my app in GE?
That the url i try to open: kml:///var/mobile/Applications/****/Documents/google_earth.kml
here the code:
NSError *error;
BOOL success;
//get the documents directory:
NSArray *paths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *fileNameKML = [NSString stringWithFormat:@"%@/google_earth.kml", documentsDirectory];
NSString *GoogleEarthfileName = [NSString stringWithFormat:@"kml://%@", fileNameKML];
//NSLog([NSString stringWithFormat:@"Google Earth filename: %@", GoogleEarthfileName]);
NSURL *newURL = [NSURL URLWithString:GoogleEarthfileName];
success = [kmlExport writeToFile:fileNameKML atomically:YES encoding:NSUTF8StringEncoding error:&error];
if (success){
if ([[UIApplication sharedApplication] canOpenURL:newURL])
{
[[UIApplication sharedApplication] openURL:newURL];
}
else
{
UIAlertView * alertView = [[[UIAlertView alloc] initWithTitle:@"Google Earth not installed" message:@"Please install Google Earth to view your tracked route." delegate:self cancelButtonTitle:NSLocalizedString(@"TXTOK", nil) otherButtonTitles: nil] autorelease];
[alertView show];
}
}
Thanks Kevin