1.5.5 • Published 4 years ago

react-native-geodb v1.5.5

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

react-native-geodb

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

Preview

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, // skip if you've set key already
    api: 'geo',
    types: 'cities'
  }}
  params={{
    language: 'en',
    limit: 10,
    offset: 0
  }}
  renderLeftButton={() => <CustomIconButton onPress={...}>}
  renderItem={({ item }) => <CustomSearchItem />}
  ListEmptyComponent={({ metadata, styles, source }) => <CustomEmptyList />}
  styles={{...}}
/>

Props

Proptypedefault
stylesobject (StyleSheet){...}
debouncenumber200
minLengthnumber2
queryobject (Query){...}
paramsobject (Params)key/value of GeoDB search url params
onSelectItemfunctionnot used if renderItem is defined
onErrorfunctionconsole.log
onResponsefunctionconsole.log
hideTextInputbooleanfalse
hidePoweredBybooleanfalse
showActivityIndicatorbooleanfalse
colorsarray[]

Query

KeyTypedefault
apistring"geo"
keystringYOUR_API_KEY
versionstring"v1"
typesstring"cities"

Params

Checkout GeoDB guides for a complete list

KeyTypedefault
limitnumber10
languageCodestring"en"
locationstring"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)

keytype
contentContainerobject (View)
textInputContainerobject (View style)
textInputobject (style)
itemContainerobject (Veiw style)
itemContentobject (View style)
itemTextobject (Text style)
emptyListobject (View style)
poweredContainerobject (View style)
poweredobject (Image style)
poweredTextobject (Text style)
separatorobject (View style)
imagePlaceholderobject (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

1.5.5

4 years ago

1.5.0

4 years ago

1.2.5

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago