Skip to content

Commit

Permalink
adding readme file
Browse files Browse the repository at this point in the history
  • Loading branch information
iSanjayAchar committed Jul 19, 2024
1 parent 11245a7 commit 7140485
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
46 changes: 45 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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);
}
```
8 changes: 4 additions & 4 deletions src/places.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IBaseResponse<IGeocodingResult>> {
public async geocode(address: string, options?: GeocodingOption): Promise<IBaseResponse<IGeocodingResult>> {
try {
let path = `${process.env.geoCodingPath}?address=${encodeURI(address)}`;

Expand Down Expand Up @@ -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.
Expand All @@ -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<IBaseResponse<IReverseGeocodingResult>> {
public async reverse_geocode(lat: string | number, lng: string| number, options?: ReverseGeocodingOption): Promise<IBaseResponse<IReverseGeocodingResult>> {
try {
let path = `${process.env.reverseGeoCodingPath}?latlng=${lat},${lng}?`;

Expand Down

0 comments on commit 7140485

Please sign in to comment.