Skip to content

Commit 27e7fd9

Browse files
author
Spike Brehm
authored
Merge pull request react-native-maps#722 from unboundfire/google-maps-ios-shapes
[iOS] Added Google Maps Circle, Polygon, Polyline, MapType Support
2 parents e536b38 + 23ce7d3 commit 27e7fd9

27 files changed

+631
-146
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/MapPolygon.js

Lines changed: 2 additions & 3 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 = {
@@ -92,7 +92,6 @@ const propTypes = {
9292
* points on the Earth's surface. The geodesic curve is constructed assuming the Earth is
9393
* a sphere.
9494
*
95-
* @platform android
9695
*/
9796
geodesic: PropTypes.bool,
9897

@@ -145,7 +144,7 @@ module.exports = decorateMapComponent(MapPolygon, {
145144
componentType: 'Polygon',
146145
providers: {
147146
google: {
148-
ios: NOT_SUPPORTED,
147+
ios: SUPPORTED,
149148
android: USES_DEFAULT_IMPLEMENTATION,
150149
},
151150
},

components/MapPolyline.js

Lines changed: 7 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 = {
@@ -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
*/
@@ -140,7 +145,7 @@ module.exports = decorateMapComponent(MapPolyline, {
140145
componentType: 'Polyline',
141146
providers: {
142147
google: {
143-
ios: NOT_SUPPORTED,
148+
ios: SUPPORTED,
144149
android: USES_DEFAULT_IMPLEMENTATION,
145150
},
146151
},

components/MapView.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const MAP_TYPES = {
3232
NONE: 'none',
3333
};
3434

35-
const ANDROID_ONLY_MAP_TYPES = [
35+
const GOOGLE_MAPS_ONLY_TYPES = [
3636
MAP_TYPES.TERRAIN,
3737
MAP_TYPES.NONE,
3838
];
@@ -208,7 +208,8 @@ const propTypes = {
208208
* - standard: standard road map (default)
209209
* - satellite: satellite view
210210
* - hybrid: satellite view with roads and points of interest overlayed
211-
* - terrain: (Android only) topographic view
211+
* - terrain: topographic view
212+
* - none: no base map
212213
*/
213214
mapType: PropTypes.oneOf(Object.values(MAP_TYPES)),
214215

@@ -502,8 +503,9 @@ class MapView extends React.Component {
502503
onMapReady: this._onMapReady,
503504
onLayout: this._onLayout,
504505
};
505-
if (Platform.OS === 'ios' && ANDROID_ONLY_MAP_TYPES.includes(props.mapType)) {
506-
props.mapType = MAP_TYPES.STANDARD;
506+
if (Platform.OS === 'ios' && props.provider === ProviderConstants.PROVIDER_DEFAULT
507+
&& GOOGLE_MAPS_ONLY_TYPES.includes(props.mapType)) {
508+
props.mapType = MAP_TYPES.standard;
507509
}
508510
props.handlePanDrag = !!props.onPanDrag;
509511
} else {

example/App.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,12 @@ class App extends React.Component {
124124
[EventListener, 'Events', true, '(incomplete)'],
125125
[MarkerTypes, 'Image Based Markers', true],
126126
[DraggableMarkers, 'Draggable Markers', true],
127-
[PolygonCreator, 'Polygon Creator'],
128-
[PolylineCreator, 'Polyline Creator'],
127+
[PolygonCreator, 'Polygon Creator', true],
128+
[PolylineCreator, 'Polyline Creator', true],
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/examples/PolygonCreator.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class PolygonCreator extends React.Component {
7979
<MapView
8080
provider={this.props.provider}
8181
style={styles.map}
82+
mapType={MapView.MAP_TYPES.HYBRID}
8283
initialRegion={this.state.region}
8384
onPress={e => this.onPress(e)}
8485
{...mapOptions}

example/ios/AirMapsExplorer.xcodeproj/project.pbxproj

Lines changed: 133 additions & 129 deletions
Large diffs are not rendered by default.

example/ios/Podfile.lock

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@ SPEC CHECKSUMS:
4646
GoogleMaps: 06589b9a38097bce0cd6e90f0fd9b5e4b4a9344c
4747
React: d80af5410aa500d0cb1bce2cc4493a584cf2ec92
4848

49-
COCOAPODS: 0.39.0
49+
PODFILE CHECKSUM: be65689c848eff5d4099a483239b72acab62f6a4
50+
51+
COCOAPODS: 1.1.1

ios/AirGoogleMaps/AIRGoogleMap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
@property (nonatomic, copy) RCTDirectEventBlock onRegionChange;
2525
@property (nonatomic, copy) RCTDirectEventBlock onRegionChangeComplete;
2626
@property (nonatomic, strong) NSMutableArray *markers;
27+
@property (nonatomic, strong) NSMutableArray *polygons;
28+
@property (nonatomic, strong) NSMutableArray *polylines;
29+
@property (nonatomic, strong) NSMutableArray *circles;
2730

2831
@property (nonatomic, assign) BOOL showsBuildings;
2932
@property (nonatomic, assign) BOOL showsTraffic;

0 commit comments

Comments
 (0)