Skip to content

Commit

Permalink
Fixed pointForCoordinate/coordinateForPoint Promises in iOS (reac…
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Apr 1, 2018
1 parent ede2bdc commit a7af797
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/ios/AirGoogleMaps/AIRGoogleMapManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ - (UIView *)view

RCT_EXPORT_METHOD(pointForCoordinate:(nonnull NSNumber *)reactTag
coordinate:(NSDictionary *)coordinate
withCallback:(RCTResponseSenderBlock)callback)
resolver: (RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
CLLocationCoordinate2D coord =
CLLocationCoordinate2DMake(
Expand All @@ -314,18 +315,19 @@ - (UIView *)view
AIRGoogleMap *mapView = (AIRGoogleMap *)view;

CGPoint touchPoint = [mapView.projection pointForCoordinate:coord];

callback(@[[NSNull null], @{
@"x": @(touchPoint.x),
@"y": @(touchPoint.y),
}]);
resolve(@{
@"x": @(touchPoint.x),
@"y": @(touchPoint.y),
});
}
}];
}

RCT_EXPORT_METHOD(coordinateForPoint:(nonnull NSNumber *)reactTag
point:(NSDictionary *)point
withCallback:(RCTResponseSenderBlock)callback)
resolver: (RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)
{
CGPoint pt = CGPointMake(
[point[@"x"] doubleValue],
Expand All @@ -340,11 +342,11 @@ - (UIView *)view
AIRGoogleMap *mapView = (AIRGoogleMap *)view;

CLLocationCoordinate2D coordinate = [mapView.projection coordinateForPoint:pt];

callback(@[[NSNull null], @{
resolve(@{
@"latitude": @(coordinate.latitude),
@"longitude": @(coordinate.longitude),
}]);
});
}
}];
}
Expand Down

0 comments on commit a7af797

Please sign in to comment.