1.0.3 • Published 9 months ago

address-autocomplete-react v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
9 months ago

react-photon-location-input

This is a React component that provides an autosuggest input box using the Photon API for location search with OpenStreetMap data. It returns the selected location's name and coordinates.

Installation

Install the component via npm:

npm install address-autocomplete-react

LiveDemo

Click here to see it in action

Usage

import React, { useState } from "react";
import LocationInput from "address-autocomplete-react";

const MyApp = () => {
  const [coords, setCoords] = useState(null);

  const handleLocationSelect = (location) => {
    setCoords([location.lat, location.lon]);
    console.log("Selected location:", location);
  };

  return (
    <div>
      <LocationInput
        placeholder="Enter Drop Location..."
        onLocationSelect={handleLocationSelect}
      />
      {coords && <p>Selected coordinates: {coords.join(", ")}</p>}
    </div>
  );
};

export default MyApp;