This JavaScript SDK provides a seamless interface to interact with the OLA Maps API, simplifying geocoding, reverse geocoding, and routing operations.
Install the SDK using npm:
npm i --save ola-maps
Or using yarn:
yarn add ola-maps
The SDK consists of two main modules:
- Places: Provides functionality for autocomplete, geocoding, and reverse geocoding. For more details, check the Places documentation.
- Routing: Enables the calculation of directions between locations. For more details, check the Routing documentation
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
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();
If you encounter any problems or have feature requests, please file an issue on our GitHub repository - https://github.com/iSanjayAchar/ola-maps-node-sdk/issues/new
Sanjay Achar |
Jeevan V |
This SDK is released under the MIT License.