Skip to content

Commit 100c50a

Browse files
Update examples and documentation to use new es6 exports
1 parent dc6bbb7 commit 100c50a

38 files changed

+189
-165
lines changed

README.md

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ versions you should add `react` as a dependency in your `package.json`.
2626

2727
[`<MapView />` Component API](docs/mapview.md)
2828

29-
[`<MapView.Marker />` Component API](docs/marker.md)
29+
[`<Marker />` Component API](docs/marker.md)
3030

31-
[`<MapView.Callout />` Component API](docs/callout.md)
31+
[`<Callout />` Component API](docs/callout.md)
3232

33-
[`<MapView.Polygon />` Component API](docs/polygon.md)
33+
[`<Polygon />` Component API](docs/polygon.md)
3434

35-
[`<MapView.Polyline />` Component API](docs/polyline.md)
35+
[`<Polyline />` Component API](docs/polyline.md)
3636

37-
[`<MapView.Circle />` Component API](docs/circle.md)
37+
[`<Circle />` Component API](docs/circle.md)
3838

39-
[`<MapView.Overlay />` Component API](docs/overlay.md)
39+
[`<Overlay />` Component API](docs/overlay.md)
4040

4141
## General Usage
4242

@@ -98,12 +98,14 @@ render() {
9898
### Rendering a list of markers on a map
9999

100100
```jsx
101+
import { Marker } from 'react-native-maps';
102+
101103
<MapView
102104
region={this.state.region}
103105
onRegionChange={this.onRegionChange}
104106
>
105107
{this.state.markers.map(marker => (
106-
<MapView.Marker
108+
<Marker
107109
coordinate={marker.latlng}
108110
title={marker.title}
109111
description={marker.description}
@@ -115,15 +117,15 @@ render() {
115117
### Rendering a Marker with a custom view
116118

117119
```jsx
118-
<MapView.Marker coordinate={marker.latlng}>
120+
<Marker coordinate={marker.latlng}>
119121
<MyCustomMarkerView {...marker} />
120-
</MapView.Marker>
122+
</Marker>
121123
```
122124

123125
### Rendering a Marker with a custom image
124126

125127
```jsx
126-
<MapView.Marker
128+
<Marker
127129
coordinate={marker.latlng}
128130
image={require('../assets/pin.png')}
129131
/>
@@ -132,19 +134,21 @@ render() {
132134
### Rendering a custom Marker with a custom Callout
133135

134136
```jsx
135-
<MapView.Marker coordinate={marker.latlng}>
137+
import { Callout } from 'react-native-maps';
138+
139+
<Marker coordinate={marker.latlng}>
136140
<MyCustomMarkerView {...marker} />
137-
<MapView.Callout>
141+
<Callout>
138142
<MyCustomCalloutView {...marker} />
139-
</MapView.Callout>
140-
</MapView.Marker>
143+
</Callout>
144+
</Marker>
141145
```
142146

143147
### Draggable Markers
144148

145149
```jsx
146150
<MapView initialRegion={...}>
147-
<MapView.Marker draggable
151+
<Marker draggable
148152
coordinate={this.state.x}
149153
onDragEnd={(e) => this.setState({ x: e.nativeEvent.coordinate })}
150154
/>
@@ -156,11 +160,13 @@ render() {
156160
#### Tile Overlay using tile server
157161

158162
```jsx
163+
import { UrlTile } from 'react-native-maps';
164+
159165
<MapView
160166
region={this.state.region}
161167
onRegionChange={this.onRegionChange}
162168
>
163-
<MapView.UrlTile
169+
<UrlTile
164170
/**
165171
* The url template of the tile server. The patterns {x} {y} {z} will be replaced at runtime
166172
* For example, http://c.tile.openstreetmap.org/{z}/{x}/{y}.png
@@ -181,11 +187,13 @@ For IOS: configure [App Transport Security](https://developer.apple.com/library/
181187
Tiles can be stored locally within device using xyz tiling scheme and displayed as tile overlay as well. This is usefull especially for offline map usage when tiles are available for selected map region within device storage.
182188

183189
```jsx
190+
import { LocalTile } from 'react-native-maps';
191+
184192
<MapView
185193
region={this.state.region}
186194
onRegionChange={this.onRegionChange}
187195
>
188-
<MapView.LocalTile
196+
<LocalTile
189197
/**
190198
* The path template of the locally stored tiles. The patterns {x} {y} {z} will be replaced at runtime
191199
* For example, /storage/emulated/0/mytiles/{z}/{x}/{y}.png
@@ -386,14 +394,14 @@ Enable lite mode on Android with `liteMode` prop. Ideal when having multiple map
386394

387395
### Animated Region
388396

389-
The MapView can accept an `MapView.AnimatedRegion` value as its `region` prop. This allows you to utilize the Animated API to control the map's center and zoom.
397+
The MapView can accept an `AnimatedRegion` value as its `region` prop. This allows you to utilize the Animated API to control the map's center and zoom.
390398

391399
```jsx
392-
import MapView from 'react-native-maps';
400+
import MapView, { AnimatedRegion, Animated } from 'react-native-maps';
393401

394402
getInitialState() {
395403
return {
396-
region: new MapView.AnimatedRegion({
404+
region: new AnimatedRegion({
397405
latitude: LATITUDE,
398406
longitude: LONGITUDE,
399407
latitudeDelta: LATITUDE_DELTA,
@@ -408,7 +416,7 @@ onRegionChange(region) {
408416

409417
render() {
410418
return (
411-
<MapView.Animated
419+
<Animated
412420
region={this.state.region}
413421
onRegionChange={this.onRegionChange}
414422
/>
@@ -421,9 +429,11 @@ render() {
421429
Markers can also accept an `AnimatedRegion` value as a coordinate.
422430

423431
```jsx
432+
import Mapview, { AnimatedRegion, Marker } from 'react-native-maps';
433+
424434
getInitialState() {
425435
return {
426-
coordinate: new MapView.AnimatedRegion({
436+
coordinate: new AnimatedRegion({
427437
latitude: LATITUDE,
428438
longitude: LONGITUDE,
429439
}),
@@ -442,7 +452,7 @@ componentWillReceiveProps(nextProps) {
442452
render() {
443453
return (
444454
<MapView initialRegion={...}>
445-
<MapView.Marker.Animated coordinate={this.state.coordinate} />
455+
<Marker.Animated coordinate={this.state.coordinate} />
446456
</MapView>
447457
);
448458
}
@@ -451,6 +461,8 @@ render() {
451461
### Take Snapshot of map
452462

453463
```jsx
464+
import MapView, { Marker } from 'react-native-maps';
465+
454466
getInitialState() {
455467
return {
456468
coordinate: {
@@ -480,7 +492,7 @@ render() {
480492
return (
481493
<View>
482494
<MapView initialRegion={...} ref={map => { this.map = map }}>
483-
<MapView.Marker coordinate={this.state.coordinate} />
495+
<Marker coordinate={this.state.coordinate} />
484496
</MapView>
485497
<Image source={{ uri: this.state.mapSnapshot.uri }} />
486498
<TouchableOpacity onPress={this.takeSnapshot}>

docs/callout.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `<MapView.Callout />` Component API
1+
# `<Callout />` Component API
22

33
## Props
44

docs/circle.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `<MapView.Circle />` Component API
1+
# `<Circle />` Component API
22

33
## Props
44

docs/marker.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# `<MapView.Marker />` Component API
1+
# `<Marker />` Component API
22

33
## Props
44

55
| Prop | Type | Default | Note |
66
|---|---|---|---|
7-
| `title` | `String` | | The title of the marker. This is only used if the <Marker /> component has no children that are an `<MapView.Callout />`, in which case the default callout behavior will be used, which will show both the `title` and the `description`, if provided.
8-
| `description` | `String` | | The description of the marker. This is only used if the <Marker /> component has no children that are an `<MapView.Callout />`, in which case the default callout behavior will be used, which will show both the `title` and the `description`, if provided.
7+
| `title` | `String` | | The title of the marker. This is only used if the <Marker /> component has no children that are a `<Callout />`, in which case the default callout behavior will be used, which will show both the `title` and the `description`, if provided.
8+
| `description` | `String` | | The description of the marker. This is only used if the <Marker /> component has no children that are a `<Callout />`, in which case the default callout behavior will be used, which will show both the `title` and the `description`, if provided.
99
| `image` | `ImageSource` | | A custom image to be used as the marker's icon. Only local image resources are allowed to be used.
1010
| `pinColor` | `Color` | | If no custom marker view or custom image is provided, the platform default pin will be used, which can be customized by this color. Ignored if a custom marker is being used.
1111
| `coordinate` | `LatLng` | | The coordinate for the marker.

docs/overlay.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `<MapView.Overlay />` Component API
1+
# `<Overlay />` Component API
22

33
## Props
44

docs/polygon.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `<MapView.Polygon />` Component API
1+
# `<Polygon />` Component API
22

33
## Props
44

docs/polyline.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# `<MapView.Polyline />` Component API
1+
# `<Polyline />` Component API
22

33
## Props
44

@@ -37,8 +37,10 @@ Gradient polylines can be created by using the `strokeColors` prop. `strokeColor
3737
Example:
3838

3939
```js
40+
import MapView, { Polyline } from 'react-native-maps';
41+
4042
<MapView>
41-
<MapView.Polyline
43+
<Polyline
4244
coordinates={[
4345
{ latitude: 37.8025259, longitude: -122.4351431 },
4446
{ latitude: 37.7896386, longitude: -122.421646 },

example/examples/AnimatedMarkers.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
TouchableOpacity,
88
} from 'react-native';
99

10-
import MapView from 'react-native-maps';
10+
import MapView, { ProviderPropType, Marker, AnimatedRegion } from 'react-native-maps';
1111

1212
const screen = Dimensions.get('window');
1313

@@ -22,7 +22,7 @@ class AnimatedMarkers extends React.Component {
2222
super(props);
2323

2424
this.state = {
25-
coordinate: new MapView.AnimatedRegion({
25+
coordinate: new AnimatedRegion({
2626
latitude: LATITUDE,
2727
longitude: LONGITUDE,
2828
}),
@@ -50,7 +50,7 @@ class AnimatedMarkers extends React.Component {
5050
longitudeDelta: LONGITUDE_DELTA,
5151
}}
5252
>
53-
<MapView.Marker.Animated
53+
<Marker.Animated
5454
coordinate={this.state.coordinate}
5555
/>
5656
</MapView>
@@ -68,7 +68,7 @@ class AnimatedMarkers extends React.Component {
6868
}
6969

7070
AnimatedMarkers.propTypes = {
71-
provider: MapView.ProviderPropType,
71+
provider: ProviderPropType,
7272
};
7373

7474
const styles = StyleSheet.create({

example/examples/AnimatedViews.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@ import {
66
Animated,
77
} from 'react-native';
88

9-
import MapView from 'react-native-maps';
9+
import {
10+
ProviderPropType,
11+
Animated as AnimatedMap,
12+
AnimatedRegion,
13+
Marker,
14+
} from 'react-native-maps';
1015
import PanController from './PanController';
1116
import PriceMarker from './AnimatedPriceMarker';
1217

@@ -191,7 +196,7 @@ class AnimatedViews extends React.Component {
191196
scale,
192197
translateY,
193198
markers,
194-
region: new MapView.AnimatedRegion({
199+
region: new AnimatedRegion({
195200
latitude: LATITUDE,
196201
longitude: LONGITUDE,
197202
latitudeDelta: LATITUDE_DELTA,
@@ -324,7 +329,7 @@ class AnimatedViews extends React.Component {
324329
onStartShouldSetPanResponder={this.onStartShouldSetPanResponder}
325330
onMoveShouldSetPanResponder={this.onMoveShouldSetPanResponder}
326331
>
327-
<MapView.Animated
332+
<AnimatedMap
328333
provider={this.props.provider}
329334
style={styles.map}
330335
region={region}
@@ -338,7 +343,7 @@ class AnimatedViews extends React.Component {
338343
} = animations[i];
339344

340345
return (
341-
<MapView.Marker
346+
<Marker
342347
key={marker.id}
343348
coordinate={marker.coordinate}
344349
>
@@ -352,10 +357,10 @@ class AnimatedViews extends React.Component {
352357
amount={marker.amount}
353358
selected={selected}
354359
/>
355-
</MapView.Marker>
360+
</Marker>
356361
);
357362
})}
358-
</MapView.Animated>
363+
</AnimatedMap>
359364
<View style={styles.itemContainer}>
360365
{markers.map((marker, i) => {
361366
const {
@@ -387,7 +392,7 @@ class AnimatedViews extends React.Component {
387392
}
388393

389394
AnimatedViews.propTypes = {
390-
provider: MapView.ProviderPropType,
395+
provider: ProviderPropType,
391396
};
392397

393398
const styles = StyleSheet.create({

example/examples/BugMarkerWontUpdate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
Dimensions,
77
TouchableOpacity,
88
} from 'react-native';
9-
import MapView from 'react-native-maps';
9+
import MapView, { ProviderPropType } from 'react-native-maps';
1010
import MyLocationMapMarker from './MyLocationMapMarker';
1111

1212
const { width, height } = Dimensions.get('window');
@@ -93,7 +93,7 @@ class BugMarkerWontUpdate extends React.Component {
9393
}
9494

9595
BugMarkerWontUpdate.propTypes = {
96-
provider: MapView.ProviderPropType,
96+
provider: ProviderPropType,
9797
};
9898

9999
const styles = StyleSheet.create({

example/examples/CachedMap.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
TouchableOpacity,
99
} from 'react-native';
1010

11-
import MapView from 'react-native-maps';
11+
import MapView, { ProviderPropType, Marker } from 'react-native-maps';
1212
import flagImg from './assets/flag-blue.png';
1313

1414
const HORIZONTAL_PADDING = 12;
@@ -69,7 +69,7 @@ class CachedMap extends React.Component {
6969
loadingIndicatorColor="#666666"
7070
loadingBackgroundColor="#eeeeee"
7171
>
72-
<MapView.Marker
72+
<Marker
7373
coordinate={region}
7474
centerOffset={{ x: -18, y: -60 }}
7575
anchor={{ x: 0.69, y: 1 }}
@@ -86,7 +86,7 @@ class CachedMap extends React.Component {
8686
}
8787

8888
CachedMap.propTypes = {
89-
provider: MapView.ProviderPropType,
89+
provider: ProviderPropType,
9090
};
9191

9292
const styles = StyleSheet.create({

0 commit comments

Comments
 (0)