Skip to content

Commit

Permalink
Update examples and documentation to use new es6 exports
Browse files Browse the repository at this point in the history
  • Loading branch information
hedgepigdaniel committed Jan 21, 2018
1 parent dc6bbb7 commit 100c50a
Show file tree
Hide file tree
Showing 38 changed files with 189 additions and 165 deletions.
60 changes: 36 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ versions you should add `react` as a dependency in your `package.json`.

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

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

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

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

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

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

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

## General Usage

Expand Down Expand Up @@ -98,12 +98,14 @@ render() {
### Rendering a list of markers on a map

```jsx
import { Marker } from 'react-native-maps';

<MapView
region={this.state.region}
onRegionChange={this.onRegionChange}
>
{this.state.markers.map(marker => (
<MapView.Marker
<Marker
coordinate={marker.latlng}
title={marker.title}
description={marker.description}
Expand All @@ -115,15 +117,15 @@ render() {
### Rendering a Marker with a custom view

```jsx
<MapView.Marker coordinate={marker.latlng}>
<Marker coordinate={marker.latlng}>
<MyCustomMarkerView {...marker} />
</MapView.Marker>
</Marker>
```

### Rendering a Marker with a custom image

```jsx
<MapView.Marker
<Marker
coordinate={marker.latlng}
image={require('../assets/pin.png')}
/>
Expand All @@ -132,19 +134,21 @@ render() {
### Rendering a custom Marker with a custom Callout

```jsx
<MapView.Marker coordinate={marker.latlng}>
import { Callout } from 'react-native-maps';

<Marker coordinate={marker.latlng}>
<MyCustomMarkerView {...marker} />
<MapView.Callout>
<Callout>
<MyCustomCalloutView {...marker} />
</MapView.Callout>
</MapView.Marker>
</Callout>
</Marker>
```

### Draggable Markers

```jsx
<MapView initialRegion={...}>
<MapView.Marker draggable
<Marker draggable
coordinate={this.state.x}
onDragEnd={(e) => this.setState({ x: e.nativeEvent.coordinate })}
/>
Expand All @@ -156,11 +160,13 @@ render() {
#### Tile Overlay using tile server

```jsx
import { UrlTile } from 'react-native-maps';

<MapView
region={this.state.region}
onRegionChange={this.onRegionChange}
>
<MapView.UrlTile
<UrlTile
/**
* The url template of the tile server. The patterns {x} {y} {z} will be replaced at runtime
* For example, http://c.tile.openstreetmap.org/{z}/{x}/{y}.png
Expand All @@ -181,11 +187,13 @@ For IOS: configure [App Transport Security](https://developer.apple.com/library/
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.

```jsx
import { LocalTile } from 'react-native-maps';

<MapView
region={this.state.region}
onRegionChange={this.onRegionChange}
>
<MapView.LocalTile
<LocalTile
/**
* The path template of the locally stored tiles. The patterns {x} {y} {z} will be replaced at runtime
* For example, /storage/emulated/0/mytiles/{z}/{x}/{y}.png
Expand Down Expand Up @@ -386,14 +394,14 @@ Enable lite mode on Android with `liteMode` prop. Ideal when having multiple map

### Animated Region

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.
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.

```jsx
import MapView from 'react-native-maps';
import MapView, { AnimatedRegion, Animated } from 'react-native-maps';

getInitialState() {
return {
region: new MapView.AnimatedRegion({
region: new AnimatedRegion({
latitude: LATITUDE,
longitude: LONGITUDE,
latitudeDelta: LATITUDE_DELTA,
Expand All @@ -408,7 +416,7 @@ onRegionChange(region) {

render() {
return (
<MapView.Animated
<Animated
region={this.state.region}
onRegionChange={this.onRegionChange}
/>
Expand All @@ -421,9 +429,11 @@ render() {
Markers can also accept an `AnimatedRegion` value as a coordinate.

```jsx
import Mapview, { AnimatedRegion, Marker } from 'react-native-maps';

getInitialState() {
return {
coordinate: new MapView.AnimatedRegion({
coordinate: new AnimatedRegion({
latitude: LATITUDE,
longitude: LONGITUDE,
}),
Expand All @@ -442,7 +452,7 @@ componentWillReceiveProps(nextProps) {
render() {
return (
<MapView initialRegion={...}>
<MapView.Marker.Animated coordinate={this.state.coordinate} />
<Marker.Animated coordinate={this.state.coordinate} />
</MapView>
);
}
Expand All @@ -451,6 +461,8 @@ render() {
### Take Snapshot of map

```jsx
import MapView, { Marker } from 'react-native-maps';

getInitialState() {
return {
coordinate: {
Expand Down Expand Up @@ -480,7 +492,7 @@ render() {
return (
<View>
<MapView initialRegion={...} ref={map => { this.map = map }}>
<MapView.Marker coordinate={this.state.coordinate} />
<Marker coordinate={this.state.coordinate} />
</MapView>
<Image source={{ uri: this.state.mapSnapshot.uri }} />
<TouchableOpacity onPress={this.takeSnapshot}>
Expand Down
2 changes: 1 addition & 1 deletion docs/callout.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `<MapView.Callout />` Component API
# `<Callout />` Component API

## Props

Expand Down
2 changes: 1 addition & 1 deletion docs/circle.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `<MapView.Circle />` Component API
# `<Circle />` Component API

## Props

Expand Down
6 changes: 3 additions & 3 deletions docs/marker.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# `<MapView.Marker />` Component API
# `<Marker />` Component API

## Props

| Prop | Type | Default | Note |
|---|---|---|---|
| `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.
| `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.
| `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.
| `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.
| `image` | `ImageSource` | | A custom image to be used as the marker's icon. Only local image resources are allowed to be used.
| `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.
| `coordinate` | `LatLng` | | The coordinate for the marker.
Expand Down
2 changes: 1 addition & 1 deletion docs/overlay.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `<MapView.Overlay />` Component API
# `<Overlay />` Component API

## Props

Expand Down
2 changes: 1 addition & 1 deletion docs/polygon.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `<MapView.Polygon />` Component API
# `<Polygon />` Component API

## Props

Expand Down
6 changes: 4 additions & 2 deletions docs/polyline.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `<MapView.Polyline />` Component API
# `<Polyline />` Component API

## Props

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

```js
import MapView, { Polyline } from 'react-native-maps';

<MapView>
<MapView.Polyline
<Polyline
coordinates={[
{ latitude: 37.8025259, longitude: -122.4351431 },
{ latitude: 37.7896386, longitude: -122.421646 },
Expand Down
8 changes: 4 additions & 4 deletions example/examples/AnimatedMarkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
TouchableOpacity,
} from 'react-native';

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

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

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

this.state = {
coordinate: new MapView.AnimatedRegion({
coordinate: new AnimatedRegion({
latitude: LATITUDE,
longitude: LONGITUDE,
}),
Expand Down Expand Up @@ -50,7 +50,7 @@ class AnimatedMarkers extends React.Component {
longitudeDelta: LONGITUDE_DELTA,
}}
>
<MapView.Marker.Animated
<Marker.Animated
coordinate={this.state.coordinate}
/>
</MapView>
Expand All @@ -68,7 +68,7 @@ class AnimatedMarkers extends React.Component {
}

AnimatedMarkers.propTypes = {
provider: MapView.ProviderPropType,
provider: ProviderPropType,
};

const styles = StyleSheet.create({
Expand Down
19 changes: 12 additions & 7 deletions example/examples/AnimatedViews.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {
Animated,
} from 'react-native';

import MapView from 'react-native-maps';
import {
ProviderPropType,
Animated as AnimatedMap,
AnimatedRegion,
Marker,
} from 'react-native-maps';
import PanController from './PanController';
import PriceMarker from './AnimatedPriceMarker';

Expand Down Expand Up @@ -191,7 +196,7 @@ class AnimatedViews extends React.Component {
scale,
translateY,
markers,
region: new MapView.AnimatedRegion({
region: new AnimatedRegion({
latitude: LATITUDE,
longitude: LONGITUDE,
latitudeDelta: LATITUDE_DELTA,
Expand Down Expand Up @@ -324,7 +329,7 @@ class AnimatedViews extends React.Component {
onStartShouldSetPanResponder={this.onStartShouldSetPanResponder}
onMoveShouldSetPanResponder={this.onMoveShouldSetPanResponder}
>
<MapView.Animated
<AnimatedMap
provider={this.props.provider}
style={styles.map}
region={region}
Expand All @@ -338,7 +343,7 @@ class AnimatedViews extends React.Component {
} = animations[i];

return (
<MapView.Marker
<Marker
key={marker.id}
coordinate={marker.coordinate}
>
Expand All @@ -352,10 +357,10 @@ class AnimatedViews extends React.Component {
amount={marker.amount}
selected={selected}
/>
</MapView.Marker>
</Marker>
);
})}
</MapView.Animated>
</AnimatedMap>
<View style={styles.itemContainer}>
{markers.map((marker, i) => {
const {
Expand Down Expand Up @@ -387,7 +392,7 @@ class AnimatedViews extends React.Component {
}

AnimatedViews.propTypes = {
provider: MapView.ProviderPropType,
provider: ProviderPropType,
};

const styles = StyleSheet.create({
Expand Down
4 changes: 2 additions & 2 deletions example/examples/BugMarkerWontUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Dimensions,
TouchableOpacity,
} from 'react-native';
import MapView from 'react-native-maps';
import MapView, { ProviderPropType } from 'react-native-maps';
import MyLocationMapMarker from './MyLocationMapMarker';

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

BugMarkerWontUpdate.propTypes = {
provider: MapView.ProviderPropType,
provider: ProviderPropType,
};

const styles = StyleSheet.create({
Expand Down
6 changes: 3 additions & 3 deletions example/examples/CachedMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
TouchableOpacity,
} from 'react-native';

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

const HORIZONTAL_PADDING = 12;
Expand Down Expand Up @@ -69,7 +69,7 @@ class CachedMap extends React.Component {
loadingIndicatorColor="#666666"
loadingBackgroundColor="#eeeeee"
>
<MapView.Marker
<Marker
coordinate={region}
centerOffset={{ x: -18, y: -60 }}
anchor={{ x: 0.69, y: 1 }}
Expand All @@ -86,7 +86,7 @@ class CachedMap extends React.Component {
}

CachedMap.propTypes = {
provider: MapView.ProviderPropType,
provider: ProviderPropType,
};

const styles = StyleSheet.create({
Expand Down
Loading

0 comments on commit 100c50a

Please sign in to comment.