Socket
Socket
Sign inDemoInstall

react-native-map-input

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-map-input

A React Native Component for Getting Location using a Map


Version published
Maintainers
1
Created
Source

React Native Map Input

A React Native Component for Getting Location using a Map

Installation

yarn add react-native-map-input

or

npm install react-native-map-input --save
You have to install:
  • react-native-maps
  • react-native-svg

Example

  1. Usage with basic React state

    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 (
        // ...
        <MapInput
          region={coordinate}
          onChange={setCoordinate}
          variant={MapInputVariants.BY_REGION} {/* or BY_MARKER if you want */}
        />
        // ...
      );
    };
    
  2. Usage with Formik

    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 (
        <Formik initialValues={initialValues} onSubmit={handleSubmit}>
          {() => (
            // ...
            <FormikMapInput
              name="location"
              variant={MapInputVariants.BY_REGION} {/* or BY_MARKER if you want */}
            />
            // ...
          )}
        </Formik>
      );
    };
    

Keywords

FAQs

Package last updated on 20 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc