Fix map annotation view layout bug

Summary:
public
When using the custom view option for MapView annotations, the view would sometimes be top-left-aligned on the coordinate instead of centered on it. This fixes that.

Reviewed By: fredliu

Differential Revision: D2776380

fb-gh-sync-id: 793bfd1c3f5b1c923caf031e01b1f6c90e544472
This commit is contained in:
Nick Lockwood
2015-12-19 09:15:38 -08:00
committed by facebook-github-bot-5
parent 04f38d381a
commit 97fe0eae6b
2 changed files with 40 additions and 16 deletions

View File

@@ -270,7 +270,7 @@ const MapView = React.createClass({
render: function() {
let children = [], {annotations, overlays} = this.props;
annotations = annotations && annotations.map((annotation: Object, index: number) => {
annotations = annotations && annotations.map((annotation: Object) => {
let {
id,
image,
@@ -329,10 +329,10 @@ const MapView = React.createClass({
}
});
}
return {
let result = {
...annotation,
tintColor: tintColor && processColor(tintColor),
image: image && resolveAssetSource(image),
image,
viewIndex,
leftCalloutViewIndex,
rightCalloutViewIndex,
@@ -341,17 +341,20 @@ const MapView = React.createClass({
leftCalloutView: undefined,
rightCalloutView: undefined,
detailCalloutView: undefined,
id: id || String(index),
};
result.id = id || encodeURIComponent(JSON.stringify(result));
result.image = image && resolveAssetSource(image);
return result;
});
overlays = overlays && overlays.map((overlay: Object, index: number) => {
overlays = overlays && overlays.map((overlay: Object) => {
let {id, fillColor, strokeColor} = overlay;
return {
let result = {
...overlay,
strokeColor: strokeColor && processColor(strokeColor),
fillColor: fillColor && processColor(fillColor),
id: id || String(index),
};
result.id = id || encodeURIComponent(JSON.stringify(result));
return result;
});
// TODO: these should be separate events, to reduce bridge traffic