From 7140485169b6df1d30eb74a7a87bd123d5d62b9a Mon Sep 17 00:00:00 2001 From: Sanjay Achar Date: Fri, 19 Jul 2024 16:30:38 +0530 Subject: [PATCH] adding readme file --- README.md | 46 +++++++++++++++++++++++++++++++++++++++++++++- src/places.ts | 8 ++++---- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7fdd22f..8c1aa9e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,23 @@ npm i -S ola-maps yarn add ola-maps ``` -### Places (Autocomplete) +### Authentication +While OLA Map APIs support two type of authentication, this SDK only supports only authentication using `API_KEY`. To generate `API_KEY`, check the documentation - https://maps.olakrutrim.com/docs/auth + +### Support +1. Places + - [x] Autocomplete + - [x] Geocode + - [x] Reverse Geocode +2. Routing + - [ ] Direction + +### Places +Comprehensive set of APIs to access OLA Maps API with ease + +#### Auto Complete +Autocomplete provides intuitive suggestions of places to be looked up. This helps accurate lookup of places based on the text provided. This solves a lot of use cases like lookup of popular places like restaurants, malls, etc. + ``` import { Places } from "ola-maps"; @@ -18,4 +34,32 @@ async function query(input) { const result = places.autocomplete(input); console.log(result); } +``` + +#### Geocode +Forward Geocoding API helps translate real-world text-based addresses into geographic coordinates. This is useful in mapping services, route planning, location-based searches, and delivery logistics. + +``` +import { Places } from "ola-maps"; + +const places = new Places("API_KEY", "VERSION"); // Version is optional + +async function query(input) { + const result = places.geocode(input); + console.log(result); +} +``` + +#### Reverse Geocode +Reverse Geocoding API helps in translating coordinates to real world text based addressing. This is helpful in scenarios like taxi pickup, taxi drop, delivery/courier, etc. + +``` +import { Places } from "ola-maps"; + +const places = new Places("API_KEY", "VERSION"); // Version is optional + +async function query(input) { + const result = places.reverse_geocode(input); + console.log(result); +} ``` \ No newline at end of file diff --git a/src/places.ts b/src/places.ts index da7a1e8..18fe63f 100644 --- a/src/places.ts +++ b/src/places.ts @@ -143,12 +143,12 @@ export class Places { } /** - * Performs geocoding based on the provided address and options. + * Performs geocode based on the provided address and options. * @param address - The address to geocode. * @param options - (Optional) Additional options to customize the request. * @returns A Promise that resolves to the geocoding results. */ - public async geocoding(address: string, options?: GeocodingOption): Promise> { + public async geocode(address: string, options?: GeocodingOption): Promise> { try { let path = `${process.env.geoCodingPath}?address=${encodeURI(address)}`; @@ -185,7 +185,7 @@ export class Places { } /** - * Performs reverse geocoding to get address details from latitude and longitude coordinates. + * Performs reverse geocode to get address details from latitude and longitude coordinates. * * @param lat - The latitude coordinate. * @param lng - The longitude coordinate. @@ -195,7 +195,7 @@ export class Places { * @returns A Promise that resolves to the reverse geocoding results. * @throws {Error} If an error occurs during the request. */ - public async reverse_geocoding(lat: string | number, lng: string| number, options?: ReverseGeocodingOption): Promise> { + public async reverse_geocode(lat: string | number, lng: string| number, options?: ReverseGeocodingOption): Promise> { try { let path = `${process.env.reverseGeoCodingPath}?latlng=${lat},${lng}?`;