JavaScript SDK for a seamless interface to interact with the OLA Maps API, simplifying geocoding, reverse geocoding, and routing operations.
npm install ola-mapsbash
npm i --save ola-maps
`
Or using yarn:
`bash
yarn add ola-maps
`$3
The SDK consists of two main modules:
1. Places: Provides functionality for autocomplete, geocoding, and reverse geocoding. For more details, check the Places documentation.
2. Routing: Enables the calculation of directions between locations. For more details, check the Routing documentation$3
This SDK supports authentication using API_KEY. Generate your API key by following the instructions in the OLA Maps documentation: https://maps.olakrutrim.com/docs/auth$3
`javascript
import { Places, Routing } from "ola-maps";const placesClient = new Places("YOUR_API_KEY");
const routingClient = new Routing("YOUR_API_KEY");
async function main() {
const autocompleteResult = await placesClient.autocomplete("Koramangala");
console.log(autocompleteResult);
const geocodeResult = await placesClient.geocode("Regent Insignia, 4th Block, 17th Main, Koramangala");
console.log(geocodeResult);
const reverseGeocodeResult = await placesClient.reverse_geocode(12.9716, 77.5946);
console.log(reverseGeocodeResult);
const origin = { lat: 12.9716, lng: 77.5946 }; // Bengaluru
const destination = { lat: 19.0760, lng: 72.8777 }; // Mumbai
const directionResult = await routingClient.direction(origin, destination);
console.log(directionResult);
}
main();
``Sanjay Achar | Jeevan V |