-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support Map.Overlay for iOS * change using image in example * add overlay support to Google Maps API for iOS * documented limitation in Overlay for iOS * fix MKMapRectMake params from 'bottom to top' to 'top to bottom' * remove limitation
- Loading branch information
Showing
17 changed files
with
400 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,4 @@ type LatLng { | |
latitude: Number, | ||
longitude: Number, | ||
} | ||
``` | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// AIRGoogleMapOverlay.h | ||
// | ||
// Created by Taro Matsuzawa on 5/3/17. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <GoogleMaps/GoogleMaps.h> | ||
#import <React/RCTBridge.h> | ||
#import "AIRMapCoordinate.h" | ||
#import "AIRGoogleMap.h" | ||
|
||
@interface AIRGoogleMapOverlay : UIView | ||
|
||
@property (nonatomic, strong) GMSGroundOverlay *overlay; | ||
@property (nonatomic, copy) NSString *imageSrc; | ||
@property (nonatomic, strong, readonly) UIImage *overlayImage; | ||
@property (nonatomic, copy) NSArray *boundsRect; | ||
@property (nonatomic, readonly) GMSCoordinateBounds *overlayBounds; | ||
|
||
@property (nonatomic, weak) RCTBridge *bridge; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// | ||
// AIRGoogleMapOverlay.m | ||
// Created by Nick Italiano on 3/5/17. | ||
// | ||
|
||
#import "AIRGoogleMapOverlay.h" | ||
|
||
#import <React/RCTEventDispatcher.h> | ||
#import <React/RCTImageLoader.h> | ||
#import <React/RCTUtils.h> | ||
#import <React/UIView+React.h> | ||
|
||
@interface AIRGoogleMapOverlay() | ||
@property (nonatomic, strong, readwrite) UIImage *overlayImage; | ||
@property (nonatomic, readwrite) GMSCoordinateBounds *overlayBounds; | ||
@end | ||
|
||
@implementation AIRGoogleMapOverlay { | ||
RCTImageLoaderCancellationBlock _reloadImageCancellationBlock; | ||
CLLocationCoordinate2D _southWest; | ||
CLLocationCoordinate2D _northEast; | ||
} | ||
|
||
- (instancetype)init | ||
{ | ||
if ((self = [super init])) { | ||
_overlay = [[GMSGroundOverlay alloc] init]; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)setImageSrc:(NSString *)imageSrc | ||
{ | ||
NSLog(@">>> SET IMAGESRC: %@", imageSrc); | ||
_imageSrc = imageSrc; | ||
|
||
if (_reloadImageCancellationBlock) { | ||
_reloadImageCancellationBlock(); | ||
_reloadImageCancellationBlock = nil; | ||
} | ||
|
||
__weak typeof(self) weakSelf = self; | ||
_reloadImageCancellationBlock = [_bridge.imageLoader loadImageWithURLRequest:[RCTConvert NSURLRequest:_imageSrc] | ||
size:weakSelf.bounds.size | ||
scale:RCTScreenScale() | ||
clipped:YES | ||
resizeMode:RCTResizeModeCenter | ||
progressBlock:nil | ||
partialLoadBlock:nil | ||
completionBlock:^(NSError *error, UIImage *image) { | ||
if (error) { | ||
NSLog(@"%@", error); | ||
} | ||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
NSLog(@">>> IMAGE: %@", image); | ||
weakSelf.overlayImage = image; | ||
weakSelf.overlay.icon = image; | ||
}); | ||
}]; | ||
|
||
} | ||
|
||
- (void)setBoundsRect:(NSArray *)boundsRect | ||
{ | ||
_boundsRect = boundsRect; | ||
|
||
_southWest = CLLocationCoordinate2DMake([boundsRect[1][0] doubleValue], [boundsRect[0][1] doubleValue]); | ||
_northEast = CLLocationCoordinate2DMake([boundsRect[0][0] doubleValue], [boundsRect[1][1] doubleValue]); | ||
|
||
_overlayBounds = [[GMSCoordinateBounds alloc] initWithCoordinate:_southWest | ||
coordinate:_northEast]; | ||
|
||
_overlay.bounds = _overlayBounds; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// | ||
// AIRGoogleMapOverlayManager.h | ||
// Created by Taro Matsuzawa on 3/5/17. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <React/RCTViewManager.h> | ||
|
||
@interface AIRGoogleMapOverlayManager : RCTViewManager | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#import "AIRGoogleMapOverlayManager.h" | ||
#import "AIRGoogleMapOverlay.h" | ||
|
||
@interface AIRGoogleMapOverlayManager() | ||
|
||
@end | ||
|
||
@implementation AIRGoogleMapOverlayManager | ||
|
||
RCT_EXPORT_MODULE() | ||
|
||
- (UIView *)view | ||
{ | ||
AIRGoogleMapOverlay *overlay = [AIRGoogleMapOverlay new]; | ||
overlay.bridge = self.bridge; | ||
return overlay; | ||
} | ||
|
||
RCT_REMAP_VIEW_PROPERTY(bounds, boundsRect, NSArray) | ||
RCT_REMAP_VIEW_PROPERTY(image, imageSrc, NSString) | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#import "AIRMapCallout.h" | ||
|
||
#import <MapKit/MapKit.h> | ||
#import <UIKit/UIKit.h> | ||
|
||
#import "RCTConvert+AirMap.h" | ||
#import <React/RCTComponent.h> | ||
#import "AIRMap.h" | ||
#import "AIRMapOverlayRenderer.h" | ||
|
||
@class RCTBridge; | ||
|
||
@interface AIRMapOverlay : UIView <MKOverlay> | ||
|
||
@property (nonatomic, strong) AIRMapOverlayRenderer *renderer; | ||
@property (nonatomic, weak) AIRMap *map; | ||
@property (nonatomic, weak) RCTBridge *bridge; | ||
|
||
@property (nonatomic, strong) NSString *name; | ||
@property (nonatomic, copy) NSString *imageSrc; | ||
@property (nonatomic, strong, readonly) UIImage *overlayImage; | ||
@property (nonatomic, copy) NSArray *boundsRect; | ||
@property (nonatomic, assign) NSInteger rotation; | ||
@property (nonatomic, assign) CGFloat transparency; | ||
@property (nonatomic, assign) NSInteger zIndex; | ||
|
||
@property (nonatomic, copy) RCTBubblingEventBlock onPress; | ||
|
||
#pragma mark MKOverlay protocol | ||
|
||
@property(nonatomic, readonly) CLLocationCoordinate2D coordinate; | ||
@property(nonatomic, readonly) MKMapRect boundingMapRect; | ||
- (BOOL)intersectsMapRect:(MKMapRect)mapRect; | ||
- (BOOL)canReplaceMapContent; | ||
|
||
@end |
Oops, something went wrong.