Coder Social home page Coder Social logo

usmansbk / react-native-geodb Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 1.0 554 KB

A simple and fully customizable GeoDB cities api component for iOS and Android React-Native apps

Home Page: https://www.npmjs.com/package/react-native-geodb

License: MIT License

JavaScript 100.00%
react react-native geodb search location cities android ios places places-autocomplete

react-native-geodb's Introduction

react-native-geodb

A simple and fully customizable GeoDB cities api component for iOS and Android React-Native apps

Preview

Screenshot_2019-10-13-02-46-32-488_com examples Screenshot_2019-10-13-02-46-43-816_com examples Screenshot_2019-10-13-00-43-13-468_com schdlr

Installation

  1. npm install react-native-geodb --save or yarn add react-native-geodb
  2. Get your GeoDB Cities API key and subscribe to the free basic plan.

...Or Use the Free Instance (without passing any API KEY) The free instance allows up to 432,000 requests/day. However, it has significantly less cities (only cities with populations of greater than 20,0000).

Example

import GeoDBCitiesSearch from 'react-native-geodb';

<GeoDBCitiesSearch
  debounce={200}
  placeholder="Search cities"
  placeholderTextColor="#f5f5f5"
  onSelectItem={(data) => console.log(data.city)}
  emptyListImagePlaceholder={require('../../../assets/emptyList.png')}
  query={{
    key: GEODB_API_KEY,
    api: 'geo',
    types: 'cities'
  }}
  params={{
    language: 'en',
    limit: 10,
    offset: 0
  }}
  renderLeftButton={() => <CustomIconButton onPress={...}>}
  renderItem={({ item }) => <CustomSearchItem />}
  ListEmptyComponent={({ metadata, styles, source }) => <CustomEmptyList />}
  styles={{...}}
/>

Props

Prop type default
styles object (StyleSheet) {...}
debounce number 200
minLength number 2
query object (Query) {...}
params object (Params) key/value of GeoDB search url params
onSelectItem function not used if renderItem is defined
onError function console.log
onResponse function console.log
hideTextInput boolean false
hidePoweredBy boolean false
showActivityIndicator boolean false
colors array []

Query

Key Type default
api string "geo"
key string YOUR_API_KEY
version string "v1"
types string "cities"

Params

Checkout GeoDB guides for a complete list

Key Type default
limit number 10
languageCode string "en"
location string "lat,lon"

Styling

GeoDBCitiesSearch can be easily customized to meet styles of your app. Pass styles props to GeoDBCitiesSearch with style object for different elements (keys for style object are listed below)

key type
contentContainer object (View)
textInputContainer object (View style)
textInput object (style)
itemContainer object (Veiw style)
itemContent object (View style)
itemText object (Text style)
emptyList object (View style)
poweredContainer object (View style)
powered object (Image style)
poweredText object (Text style)
separator object (View style)
imagePlaceholder object (Image style)

Geocoder

import { Geocoder } from 'react-native-geodb';

// Returns a promise of nearby cities of the given location object
Geocoder({ lat: xxxx, lng: xxxx }, key).then(response => {
  console.log(response);
});

License

MIT

Authors

react-native-geodb's People

Contributors

usmansbk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

voltisjakupi0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.