Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Mason's answer really helped me. You'll need some modifications such as setting the absolute value of longitude &amp; latitude. Here's a code snippet of using CoreLocation + Image I/O to write an UIImage to disk with GPS information:</p> <pre><code>- (BOOL)writeCGImage:(CGImageRef)theImage toURL:(NSURL*)url withType:(CFStringRef)imageType andOptions:(CFDictionaryRef)options { CGImageDestinationRef myImageDest = CGImageDestinationCreateWithURL((CFURLRef)url, imageType, 1, nil); CGImageDestinationAddImage(myImageDest, theImage, options); BOOL success = CGImageDestinationFinalize(myImageDest); // Memory Mangement CFRelease(myImageDest); if (options) CFRelease(options); return success; } - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { if (newLocation) { [manager stopUpdatingLocation]; // Create formatted date NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"UTC"]; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setTimeZone:timeZone]; [formatter setDateFormat:@"HH:mm:ss.SS"]; // Create GPS Dictionary NSDictionary *gpsDict = [NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithFloat:fabs(newLocation.coordinate.latitude)], kCGImagePropertyGPSLatitude , ((newLocation.coordinate.latitude &gt;= 0) ? @"N" : @"S"), kCGImagePropertyGPSLatitudeRef , [NSNumber numberWithFloat:fabs(newLocation.coordinate.longitude)], kCGImagePropertyGPSLongitude , ((newLocation.coordinate.longitude &gt;= 0) ? @"E" : @"W"), kCGImagePropertyGPSLongitudeRef , [formatter stringFromDate:[newLocation timestamp]], kCGImagePropertyGPSTimeStamp , nil]; // Memory Management [formatter release]; // Set GPS Dictionary to be part of media Metadata // NOTE: mediaInfo in this sample is dictionary object returned in UIImagePickerController delegate: // imagePickerController:didFinishPickingMediaWithInfo if (mediaInfo &amp;&amp; [mediaInfo objectForKey:UIImagePickerControllerMediaMetadata] &amp;&amp; gpsDict) { [[mediaInfo objectForKey:UIImagePickerControllerMediaMetadata] setValue:gpsDict forKey:@"{GPS}"]; } // Save Image if([self writeCGImage:[image CGImage] toURL:imageSaveURL withType:kUTTypeJPEG andOptions:(CFDictionaryRef)[mediaInfo objectForKey:UIImagePickerControllerMediaMetadata]]) { // Image is written to device } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload