Phonegap似乎自动将EXIF数据添加到使用相机拍摄的Jpeg图像中,从而触发位置服务警报。 有两种方法,以防止这种情况发生:
1 - 指定PNG的拍摄画面的格式(默认的PhoneGap使用JPEG包含EXIF数据)
encodingType=navigator.camera.EncodingType;
function capturePhotoEdit() {
navigator.camera.getPicture(onPhotoDataSuccess, onFail, { encodingType: encodingType.PNG, destinationType: destinationType.DATA_URL });
}
2 - 如果你想要使用JPEG而不是PNG图像,则必须在第312行和第322行之间的CordovaLib/Classes/CDVCamera.m中注释掉这些行。这是将EXIF数据添加到图片的代码。
NSDictionary *controllerMetadata = [info objectForKey:@"UIImagePickerControllerMediaMetadata"];
if (controllerMetadata) {
self.data = data;
self.metadata = [[NSMutableDictionary alloc] init];
NSMutableDictionary *EXIFDictionary = [[controllerMetadata objectForKey:(NSString *)kCGImagePropertyExifDictionary]mutableCopy];
if (EXIFDictionary) [self.metadata setObject:EXIFDictionary forKey:(NSString *)kCGImagePropertyExifDictionary];
[[self locationManager] startUpdatingLocation];
return;
}