Skip to content

Commit b6eaf8f

Browse files
Nick ItalianoExilz
authored andcommitted
Added ios google maps circle support
1 parent 7a24e4d commit b6eaf8f

File tree

11 files changed

+155
-4
lines changed

11 files changed

+155
-4
lines changed

components/MapCircle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
} from 'react-native';
55
import decorateMapComponent, {
66
USES_DEFAULT_IMPLEMENTATION,
7-
NOT_SUPPORTED,
7+
SUPPORTED,
88
} from './decorateMapComponent';
99

1010
const propTypes = {
@@ -140,7 +140,7 @@ module.exports = decorateMapComponent(MapCircle, {
140140
componentType: 'Circle',
141141
providers: {
142142
google: {
143-
ios: NOT_SUPPORTED,
143+
ios: SUPPORTED,
144144
android: USES_DEFAULT_IMPLEMENTATION,
145145
},
146146
},

components/MapPolyline.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ const propTypes = {
2626
*/
2727
onPress: PropTypes.func,
2828

29+
/**
30+
* The fill color to use for the path.
31+
*/
32+
fillColor: PropTypes.string,
33+
2934
/**
3035
* The stroke width to use for the path.
3136
*/

example/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class App extends React.Component {
129129
[AnimatedViews, 'Animating with MapViews'],
130130
[AnimatedMarkers, 'Animated Marker Position'],
131131
[Callouts, 'Custom Callouts', true],
132-
[Overlays, 'Circles, Polygons, and Polylines', true, '(ios error)'],
132+
[Overlays, 'Circles, Polygons, and Polylines', true],
133133
[DefaultMarkers, 'Default Markers', true],
134134
[CustomMarkers, 'Custom Markers', true],
135135
[TakeSnapshot, 'Take Snapshot', true, '(incomplete)'],

example/examples/Overlays.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ class Overlays extends React.Component {
8282
<MapView.Circle
8383
center={circle.center}
8484
radius={circle.radius}
85-
fillColor="rgba(200, 0, 0, 0.5)"
85+
fillColor="rgba(255, 255, 255, 1)"
8686
strokeColor="rgba(0,0,0,0.5)"
87+
zIndex={2}
88+
strokeWidth={2}
8789
/>
8890
<MapView.Polygon
8991
coordinates={polygon}

example/ios/AirMapsExplorer.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
8620CC911DBD814A00B79BFE /* AIRGoogleMapPolylineManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8620CC821DBD814A00B79BFE /* AIRGoogleMapPolylineManager.m */; };
4646
8620CC921DBD814A00B79BFE /* DummyView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8620CC841DBD814A00B79BFE /* DummyView.m */; };
4747
8620CC931DBD814A00B79BFE /* RCTConvert+GMSMapViewType.m in Sources */ = {isa = PBXBuildFile; fileRef = 8620CC861DBD814A00B79BFE /* RCTConvert+GMSMapViewType.m */; };
48+
8697D6221DBEDE6100DB7D0F /* AIRGoogleMapCircle.m in Sources */ = {isa = PBXBuildFile; fileRef = 8697D6211DBEDE6100DB7D0F /* AIRGoogleMapCircle.m */; };
49+
8697D6251DBEE22B00DB7D0F /* AIRGoogleMapCircleManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 8697D6241DBEE22B00DB7D0F /* AIRGoogleMapCircleManager.m */; };
4850
C9315A21AD5A149EB5B40F29 /* Pods_AirMapsExplorer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24EB66BA0860A4DCD4CA3D77 /* Pods_AirMapsExplorer.framework */; };
4951
/* End PBXBuildFile section */
5052

@@ -139,6 +141,10 @@
139141
8620CC841DBD814A00B79BFE /* DummyView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DummyView.m; sourceTree = "<group>"; };
140142
8620CC851DBD814A00B79BFE /* RCTConvert+GMSMapViewType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "RCTConvert+GMSMapViewType.h"; sourceTree = "<group>"; };
141143
8620CC861DBD814A00B79BFE /* RCTConvert+GMSMapViewType.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "RCTConvert+GMSMapViewType.m"; sourceTree = "<group>"; };
144+
8697D6201DBEDE6100DB7D0F /* AIRGoogleMapCircle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIRGoogleMapCircle.h; sourceTree = "<group>"; };
145+
8697D6211DBEDE6100DB7D0F /* AIRGoogleMapCircle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AIRGoogleMapCircle.m; sourceTree = "<group>"; };
146+
8697D6231DBEE22B00DB7D0F /* AIRGoogleMapCircleManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AIRGoogleMapCircleManager.h; sourceTree = "<group>"; };
147+
8697D6241DBEE22B00DB7D0F /* AIRGoogleMapCircleManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AIRGoogleMapCircleManager.m; sourceTree = "<group>"; };
142148
86C3F1E16CFF1D84E5317F85 /* Pods-AirMapsExplorer.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AirMapsExplorer.debug.xcconfig"; path = "Pods/Target Support Files/Pods-AirMapsExplorer/Pods-AirMapsExplorer.debug.xcconfig"; sourceTree = "<group>"; };
143149
/* End PBXFileReference section */
144150

@@ -315,6 +321,10 @@
315321
8620CC841DBD814A00B79BFE /* DummyView.m */,
316322
8620CC851DBD814A00B79BFE /* RCTConvert+GMSMapViewType.h */,
317323
8620CC861DBD814A00B79BFE /* RCTConvert+GMSMapViewType.m */,
324+
8697D6201DBEDE6100DB7D0F /* AIRGoogleMapCircle.h */,
325+
8697D6211DBEDE6100DB7D0F /* AIRGoogleMapCircle.m */,
326+
8697D6231DBEE22B00DB7D0F /* AIRGoogleMapCircleManager.h */,
327+
8697D6241DBEE22B00DB7D0F /* AIRGoogleMapCircleManager.m */,
318328
);
319329
name = AirGoogleMaps;
320330
path = ../../ios/AirGoogleMaps;
@@ -505,9 +515,11 @@
505515
21D346661D933B8C002BAD8A /* AIRMapUrlTileManager.m in Sources */,
506516
8620CC931DBD814A00B79BFE /* RCTConvert+GMSMapViewType.m in Sources */,
507517
2166AB301D82EC56007538D7 /* AIRMapMarker.m in Sources */,
518+
8697D6221DBEDE6100DB7D0F /* AIRGoogleMapCircle.m in Sources */,
508519
2166AB321D82EC56007538D7 /* AIRMapPolygon.m in Sources */,
509520
13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */,
510521
2166AB3E1D82EC56007538D7 /* RCTConvert+MoreMapKit.m in Sources */,
522+
8697D6251DBEE22B00DB7D0F /* AIRGoogleMapCircleManager.m in Sources */,
511523
13B07FC11A68108700A75B9A /* main.m in Sources */,
512524
2166AB331D82EC56007538D7 /* AIRMapPolygonManager.m in Sources */,
513525
8620CC901DBD814A00B79BFE /* AIRGoogleMapPolyline.m in Sources */,

ios/AirGoogleMaps/AIRGoogleMap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
@property (nonatomic, strong) NSMutableArray *markers;
2727
@property (nonatomic, strong) NSMutableArray *polygons;
2828
@property (nonatomic, strong) NSMutableArray *polylines;
29+
@property (nonatomic, strong) NSMutableArray *circles;
2930

3031
@property (nonatomic, assign) BOOL showsBuildings;
3132
@property (nonatomic, assign) BOOL showsTraffic;

ios/AirGoogleMaps/AIRGoogleMap.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import "AIRGoogleMapMarker.h"
1010
#import "AIRGoogleMapPolygon.h"
1111
#import "AIRGoogleMapPolyline.h"
12+
#import "AIRGoogleMapCircle.h"
1213
#import <GoogleMaps/GoogleMaps.h>
1314
#import <MapKit/MapKit.h>
1415
#import "RCTConvert+MapKit.h"
@@ -77,6 +78,7 @@ - (instancetype)init
7778
_markers = [NSMutableArray array];
7879
_polygons = [NSMutableArray array];
7980
_polylines = [NSMutableArray array];
81+
_circles = [NSMutableArray array];
8082
_initialRegionSet = false;
8183
}
8284
return self;
@@ -114,6 +116,10 @@ - (void)insertReactSubview:(id<RCTComponent>)subview atIndex:(NSInteger)atIndex
114116
AIRGoogleMapPolyline *polyline = (AIRGoogleMapPolyline*)subview;
115117
polyline.polyline.map = self;
116118
[self.polylines addObject:polyline];
119+
} else if ([subview isKindOfClass:[AIRGoogleMapCircle class]]) {
120+
AIRGoogleMapCircle *circle = (AIRGoogleMapCircle*)subview;
121+
circle.circle.map = self;
122+
[self.circles addObject:circle];
117123
}
118124
[_reactSubviews insertObject:(UIView *)subview atIndex:(NSUInteger) atIndex];
119125
}
@@ -137,6 +143,10 @@ - (void)removeReactSubview:(id<RCTComponent>)subview {
137143
AIRGoogleMapPolyline *polyline = (AIRGoogleMapPolyline*)subview;
138144
polyline.polyline.map = nil;
139145
[self.polylines removeObject:polyline];
146+
} else if ([subview isKindOfClass:[AIRGoogleMapCircle class]]) {
147+
AIRGoogleMapCircle *circle = (AIRGoogleMapCircle*)subview;
148+
circle.circle.map = nil;
149+
[self.circles removeObject:circle];
140150
}
141151
[_reactSubviews removeObject:(UIView *)subview];
142152
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// AIRGoogleMapsCircle.h
3+
//
4+
// Created by Nick Italiano on 10/24/16.
5+
//
6+
7+
#import <GoogleMaps/GoogleMaps.h>
8+
#import "AIRMapCoordinate.h"
9+
10+
@interface AIRGoogleMapCircle : UIView
11+
12+
@property (nonatomic, strong) GMSCircle *circle;
13+
@property (nonatomic, assign) double radius;
14+
@property (nonatomic, assign) CLLocationCoordinate2D centerCoordinate;
15+
@property (nonatomic, assign) UIColor *strokeColor;
16+
@property (nonatomic, assign) double strokeWidth;
17+
@property (nonatomic, assign) UIColor *fillColor;
18+
@property (nonatomic, assign) int zIndex;
19+
20+
@end
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//
2+
// AIRGoogleMapsCircle.m
3+
//
4+
// Created by Nick Italiano on 10/24/16.
5+
//
6+
#import <UIKit/UIKit.h>
7+
#import "AIRGoogleMapCircle.h"
8+
#import <GoogleMaps/GoogleMaps.h>
9+
#import "RCTUtils.h"
10+
11+
@implementation AIRGoogleMapCircle
12+
13+
- (instancetype)init
14+
{
15+
if (self = [super init]) {
16+
_circle = [[GMSCircle alloc] init];
17+
}
18+
return self;
19+
}
20+
21+
- (void)setRadius:(double)radius
22+
{
23+
_radius = radius;
24+
_circle.radius = radius;
25+
}
26+
27+
- (void)setCenterCoordinate:(CLLocationCoordinate2D)centerCoordinate
28+
{
29+
_centerCoordinate = centerCoordinate;
30+
_circle.position = centerCoordinate;
31+
}
32+
33+
-(void)setStrokeColor:(UIColor *)strokeColor
34+
{
35+
_strokeColor = strokeColor;
36+
_circle.strokeColor = strokeColor;
37+
}
38+
39+
-(void)setStrokeWidth:(double)strokeWidth
40+
{
41+
_strokeWidth = strokeWidth;
42+
_circle.strokeWidth = strokeWidth;
43+
}
44+
45+
-(void)setFillColor:(UIColor *)fillColor
46+
{
47+
_fillColor = fillColor;
48+
_circle.fillColor = fillColor;
49+
}
50+
51+
-(void)setZIndex:(int)zIndex
52+
{
53+
_zIndex = zIndex;
54+
_circle.zIndex = zIndex;
55+
}
56+
57+
@end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//
2+
// AIRGoogleMapCircleManager.h
3+
//
4+
// Created by Nick Italiano on 10/24/16.
5+
//
6+
7+
#import "RCTViewManager.h"
8+
9+
@interface AIRGoogleMapCircleManager : RCTViewManager
10+
11+
@end

0 commit comments

Comments
 (0)