Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/a7medev/react-native-map-input

A React Native Component for Getting Location using a Map
https://github.com/a7medev/react-native-map-input

android formik forms ios react react-native react-native-maps

Last synced: 6 days ago
JSON representation

A React Native Component for Getting Location using a Map

Awesome Lists containing this project

README

        

# React Native Map Input

A React Native Component for Getting Location using a Map


### Installation

```sh
yarn add react-native-map-input
```

or

```sh
npm install react-native-map-input --save
```

#### You have to install:

- [react-native-maps](https://github.com/react-native-maps/react-native-maps/blob/master/docs/installation.md)
- [react-native-svg](https://github.com/react-native-svg/react-native-svg#installation)

### Example

1. Usage with basic React state

```jsx
import React, { useState } from 'react';
import MapInput, { MapInputVariant } from 'react-native-map-input';

const MyForm = () => {
const [coordinate, setCoordinate] = useState({
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
});

return (
// ...

// ...
);
};
```

2. Usage with Formik

```jsx
import React from 'react';
import { Formik } from 'formik';
import FormikMapInput from 'react-native-map-input/FormikMapInput';

const initialValues = {
// ...
location: {
latitude: 37.78825,
longitude: -122.4324,
latitudeDelta: 0.0922,
longitudeDelta: 0.0421,
},
// ...
};

const MyForm = () => {
const handleSubmit = (data) => {
console.log(data.location);
};

return (

{() => (
// ...

// ...
)}

);
};
```