@loadsmart/utils-geolocation

useful functions for dealing with geolocation data

Usage no npm install needed!

<script type="module">
  import loadsmartUtilsGeolocation from 'https://cdn.skypack.dev/@loadsmart/utils-geolocation';
</script>

README

BundlePhobia BundlePhobia

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.