簡體   English   中英

如何獲取已拍攝照片或已拍攝照片的位置(經度/緯度)

[英]How do I get the location (lat/lng) of a picture taken or a picture already taken

這似乎是重復的,但是如蘋果開發人員文檔所示,自iOS 9.0起不推薦使用Assets Library框架(大多數答案用於同一問題的當前框架)。

我需要做的是從當前正在拍攝的照片或以前已拍攝的照片中獲取經緯度(在具有位置標記的iOS 5+設備上)。 一些示例代碼會很棒

謝謝

嘗試這個

NSData* pngData =  UIImageJPEGRepresentation(image, 1.0);

CGImageSourceRef mySourceRef = CGImageSourceCreateWithData((CFDataRef)pngData, NULL);

if (mySourceRef != NULL)
{
    NSDictionary *myMetadata = (__bridge NSDictionary *)CGImageSourceCopyPropertiesAtIndex(mySourceRef,0,NULL);
    NSDictionary *GPSDictionary = [myMetadata objectForKey:(NSString *)kCGImagePropertyGPSDictionary];

    NSLog([GPSDictionary valueForKey:(NSString*)kCGImagePropertyGPSLongitude]);
    NSLog([GPSDictionary valueForKey:(NSString*)kCGImagePropertyGPSLatitude]);

}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM