Home

Awesome

OpenStreetMapSearchPlace

NPM version NPM downloads

A React Native component to search places using OpenStreetMap

Demo

<img src="./Screenrecorder-2024-05-18-14-29-50-492.gif" width="250">

Requirements

node v20.13.1

Installation

npm install react-native-openstreetmap-search-places
yarn add react-native-openstreetmap-search-places

Usage

import {useState} from 'react'
import {OpenStreetMapSearchPlace, LocationType} from 'react-native-openstreetmap-search-places'

const MyComponent = () => {
    const [location, setLocation] = useState<LocationType | undefined>(undefined)

    return (
        <OpenStreetMapSearchPlace
            location={location}
            setLocation={setLocation}
            lang='en'
            noResultFoundText='No result found'
            placeHolder='Search place'
            searchPlaceHolder='Enter address'
            mode='outlined'
            style={{
                height: 61, 
                backgroundColor: '#C7E9FD'
            }}
            contentStyle={{fontFamily: 'Roboto'}}
            outlineStyle={{
                borderRadius: 14, 
                borderWidth: 0, 
                marginHorizontal: 2
            }}
            searchBarStyle={{
                backgroundColor: '#C7E9FD',
                borderRadius: 12,
                borderWidth: 0,
                marginTop: 2,
            }}
            searchBarInputStyle={{fontFamily: 'Roboto'}}
            searchResultLabelStyle={{fontSize: 14}}
            modalStyle={{borderRadius: 14}}
            loaderColor='blue'
            loaderSize='small'
            modalBgColor='white'
            dismissable
        />
    )
}

export default MyComponent

Props

PropertyTypeRequiredDescription
locationLocationTypeTrueLocation data of searched value
setLocationfunctionTrueSet location value of searched value
langStringFalseLanguage used to search places (default en)
noResultFoundTextStringFalseText to display when no result found
placeHolderStringFalseInput text component placeholder
searchPlaceHolderStringFalseSearch input text placeholder
modeStringTrueText input style display (eg: outlined or flat)
styleStyleProp<TextStyle>FalseInput text component style
contentStyleStyleProp<TextStyle>FalseInput text component content style
outlineStyleStyleProp<ViewStyle>FalseInput text component outline style
searchBarStyleStyleProp<TextStyle>FalseSearch bar component style
searchBarInputStyleStyleProp<TextStyle>FalseSearch input text component style
searchResultLabelStyleStyleProp<TextStyle>FalseSearch result label style
modalStyleStyleProp<ViewStyle>FalseSearch results modal custom style
loaderColorStringFalseLoader color (default blue)
loaderSizeString or NumberTrueLoader size (eg: 12, small or large)
loaderColorStringTrueLoader color
modalBgColorStringTrueModal background color
dismissableBooleanTrueSet if modal dismissable
iconStringFalseInput text component left icon. (See icons list)
iconSizeNumberFalseInput text component left icon size

License

The MIT License (MIT). Please see License File for more information.

Changelog

Please see CHANGELOG for more information what has changed recently.