#If OBJC
#import "iGoogleMaps.h"
#import <GoogleMaps/GoogleMaps.h>
- (NSArray*) coordinateToScreen:(GMSProjection*)projection :(B4ILatLng*)ll {
CGPoint p = [projection pointForCoordinate:CLLocationCoordinate2DMake(ll.Latitude, ll.Longitude)];
return @[@(p.x), @(p.y)];
}
- (B4ILatLng*) screenToCoordinate:(GMSProjection*)projection :(double)x :(double)y {
CLLocationCoordinate2D c = [projection coordinateForPoint:CGPointMake(x, y)];
B4ILatLng* ll = [B4ILatLng new];
[ll Initialize:c.latitude :c.longitude];
return ll;
}
- (NSObject*) createMapStyle:(NSString*)json {
return [GMSMapStyle styleWithJSONString:json error:nil];
}
- (NSObject*)createCircle:(double)lat :(double)lon :(double)radius {
return [GMSCircle circleWithPosition:CLLocationCoordinate2DMake(lat, lon) radius:(CLLocationDistance)radius];
}
- (NSObject*)createBounds:(B4ILatLng*)ne :(B4ILatLng*)sw {
return [[GMSCoordinateBounds alloc]
initWithCoordinate:CLLocationCoordinate2DMake(ne.Latitude, ne.Longitude)
coordinate:CLLocationCoordinate2DMake(sw.Latitude, sw.Longitude)];
}
- (BOOL)boundsContain:(GMSCoordinateBounds*) bounds :(B4ILatLng*) ll {
return [bounds containsCoordinate:CLLocationCoordinate2DMake(ll.Latitude, ll.Longitude)];
}
- (NSObject*)createBoundsIncluding:(NSArray*)points {
GMSCoordinateBounds* bounds = [GMSCoordinateBounds new];
for (B4ILatLng* ll in points) {
bounds = [bounds includingCoordinate:CLLocationCoordinate2DMake(ll.Latitude, ll.Longitude)];
}
return bounds;
}
- (NSObject*)createPath:(NSArray*)points {
GMSMutablePath* p = [GMSMutablePath new];
for (B4ILatLng* ll in points) {
[p addCoordinate:CLLocationCoordinate2DMake(ll.Latitude, ll.Longitude)];
}
return p;
}
- (NSObject*)coordinateBoundsFromProjection:(GMSProjection*) p {
return [[GMSCoordinateBounds alloc]initWithRegion: [p visibleRegion]];
}
- (void)getLatLngFromBounds:(GMSCoordinateBounds*) bounds :(B4ILatLng*) northEast :(B4ILatLng*) southWest {
[northEast Initialize:bounds.northEast.latitude :bounds.northEast.longitude];
[southWest Initialize:bounds.southWest.latitude :bounds.southWest.longitude];
}
@end
@implementation B4IMapDelegate (override)
- (UIView*)mapView:(GMSMapView*)mapView markerInfoWindow:(GMSMarker*)marker {
return [B4IObjectWrapper raiseEvent:mapView :@"_markerinfowindow:" :@[marker]];
}
#End If