1//
2//  AIRGoogleMapCallout.m
3//  AirMaps
4//
5//  Created by Gil Birman on 9/6/16.
6//
7//
8
9#ifdef HAVE_GOOGLE_MAPS
10
11#import "AIRGoogleMapCallout.h"
12#import <React/RCTUtils.h>
13#import <React/RCTView.h>
14#import <React/RCTBridge.h>
15
16@implementation AIRGoogleMapCallout
17
18- (BOOL) isPointInside:(CGPoint)pointInCallout {
19    if (!self.alphaHitTest)
20        return TRUE;
21    CGFloat alpha = [self alphaOfPoint:pointInCallout];
22    return alpha >= 0.01;
23}
24
25- (CGFloat) alphaOfPoint:(CGPoint)point {
26    unsigned char pixel[4] = {0};
27    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
28    CGContextRef context = CGBitmapContextCreate(pixel, 1, 1, 8, 4, colorSpace, kCGBitmapAlphaInfoMask & kCGImageAlphaPremultipliedLast);
29    CGContextTranslateCTM(context, -point.x, -point.y);
30    [self.layer renderInContext:context];
31    CGContextRelease(context);
32    CGColorSpaceRelease(colorSpace);
33    return pixel[3]/255.0;
34}
35
36
37@end
38
39#endif
40