@loadsmart/utils-geolocation
v0.3.1
Published
useful functions for dealing with geolocation data
Downloads
582
Readme
utils-geolocation
useful functions for dealing with geolocation data
Install via NPM
$ npm i @loadsmart/utils-geolocation --save
Install via yarn
$ yarn add @loadsmart/utils-geolocation
Usage
import React from 'react'
import {
isValidGeoSuggestion
} from '@loadsmart/utils-geolocation'
export default ({geoData}) => (
<div>
{ isValidGeoSuggestion(geoSuggestionData) ? <Map data={geoData} /> : <Error /> }
</div>
)
Available Functions
These are the functions available at this library:
gMapsToAddressComponentsObject(gmaps, config)
Converts a gmaps object containing the adress_components
field to an object in the form:
{
"city": "City Name",
"state": "ST",
"country": "CT",
"zipcode": "00000"
}
isValidGeoSuggestion(geoSuggestion)
Checks if the passed geoSuggestion is a valid geo suggestion object, containing all required fields (location, gmaps, and description), returns a boolean.