我正在开发一个包含在地图上显示图片功能的Android应用。
如果.jpg文件中有位置数据,我该如何提取它们?
Todd,非常感谢。
这里有一个很好的教程,可以帮助您访问包含所需GPS信息的jpg文件的exif数据:
http://android-coding.blogspot.com/2011/10/read-exif-of-jpg-file-using.html
在官方文档中描述了相应的类:
http://developer.android.com/reference/android/media/ExifInterface.html
还可以找到有用的文章(转换GPS信息):
http://android-coding.blogspot.com/2011/10/convert-gps-tag-of-exifinterface-to.html
try {
final ExifInterface exifInterface = new ExifInterface(imagePath);
float[] latLong = new float[2];
if (exifInterface.getLatLong(latLong)) {
// Do stuff with lat / long...
}
} catch (IOException e) {
logger.info("Couldn't read exif info: " + e.getLocalizedMessage());
}