address-autocomplete-react
v1.0.3
Published
Address autocomplete - A package for inputbox with autocomplete/autosuggest feature to allow users to search address across the globe. Using Photon / komoot geocoder for autocomplete. This is a React component that provides an autosuggest input box using
Downloads
12
Maintainers
Readme
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;