Skip to content

Commit

Permalink
Update AirMapMarker to use loadImageWithURLRequest (react-native-maps…
Browse files Browse the repository at this point in the history
…#389)

[`loadImageWithTag`](https://github.com/facebook/react-native/blob/ba4c34c0db004cda9fb561b3bdf5224d518ab32d/Libraries/Image/RCTImageLoader.m#L755) is deprecated and shows warnings on RN 0.29.

### Test Plan

On iOS, render a map with a marker that has image prop set. See marker is rendered correctly and no deprecation warnings.

```
<MapView ...>
  <MapView.Marker ... image={require('./pin.png')} />
</MapView>
```
  • Loading branch information
paulshen authored and Adel Grimm committed Dec 1, 2016
1 parent aa3d4b3 commit 2d00b39
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions ios/AirMaps/AIRMapMarker.m
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,21 @@ - (void)setImageSrc:(NSString *)imageSrc
_reloadImageCancellationBlock();
_reloadImageCancellationBlock = nil;
}
_reloadImageCancellationBlock = [_bridge.imageLoader loadImageWithTag:_imageSrc
size:self.bounds.size
scale:RCTScreenScale()
resizeMode:UIViewContentModeCenter
progressBlock:nil
completionBlock:^(NSError *error, UIImage *image) {
if (error) {
// TODO(lmr): do something with the error?
NSLog(@"%@", error);
}
dispatch_async(dispatch_get_main_queue(), ^{
self.image = image;
});
}];
_reloadImageCancellationBlock = [_bridge.imageLoader loadImageWithURLRequest:[RCTConvert NSURLRequest:_imageSrc]
size:self.bounds.size
scale:RCTScreenScale()
clipped:YES
resizeMode:UIViewContentModeCenter
progressBlock:nil
completionBlock:^(NSError *error, UIImage *image) {
if (error) {
// TODO(lmr): do something with the error?
NSLog(@"%@", error);
}
dispatch_async(dispatch_get_main_queue(), ^{
self.image = image;
});
}];
}

- (void)setPinColor:(UIColor *)pinColor
Expand Down

0 comments on commit 2d00b39

Please sign in to comment.