npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-ola-maps-wrapper

v1.0.4

Published

A React wrapper for the Ola Maps SDK, providing an easy-to-use component for integrating Ola Maps into your React applications.

Downloads

390

Readme

React Ola Maps

A React wrapper for the Ola Maps SDK, providing an easy-to-use component for integrating Ola Maps into your React applications.

Features

  • Simple integration of Ola Maps in React applications
  • Customizable map container
  • Support for markers and other Ola Maps features
  • TypeScript support

Screenshots

App Screenshot

Installation

To install the package, run:

npm install react-ola-maps-wrapper

or if you're using yarn:

yarn add react-ola-maps-wrapper

Note: This package has peer dependencies of react and react-dom, so make sure these are installed in your project.

Usage

First, make sure you have an API key from Ola Maps. Then, you can use the MapContainer component in your React application:

import React from 'react';
import MapContainer from 'react-ola-maps-wrapper';

const App = () => {
  return (
    <div>
      <h1>My Map App</h1>
      <MapContainer 
        apiKey="YOUR_OLA_MAPS_API_KEY"
        width="100%"
        height="400px"
        center={{ latitude: 77.61648476788898, longitude: 12.931423492103944 }}
        zoom={15}
      />
    </div>
  );
};

export default App;

API Reference

MapContainer

The main component provided by this package.

Props:

  • apiKey (string, required): Your Ola Maps API key.

  • width (string, required): The width of the map container. Default: '100%'.

  • height (string, required): The height of the map container. Default: '400px'.

  • className (string, optional): Additional CSS class for the map container.

  • markers (Array, optional): An array of marker objects to display on the map. Each marker object should have longitude and latitude properties. Other Optional properties are also included, eg : element, offset, anchor , draggable, popUp.

  • mapEventListners(Object, optional) : An Object containing event listeners onLoad , onClick, onFail etc.

  • showCompass(Boolean, optional) : An boolean to show the compass button.

  • showZoom(Boolean, optional) : An boolean to show the zoom button.

Types


export interface Position {
    latitude: number;
    longitude: number;
}

export interface MapContainerProps {
    apiKey: string;
    width: string;
    height: string;
    className?: string;
    markers?: Marker[];
    center : Position;
    zoom: number;
    mapEventListners?: MapEventListners;
    showCompass?: boolean;
    showZoom?: boolean;
}

export interface MapEventListners {
    onLoad?: (e: any) => void;
    onClick?: (e: any) => void;
    onFail?: (e: any) => void;
    onIdle?: (e: any) => void;
    onMove?: (e: any) => void;
    onMoveStart?: (e: any) => void;
    onMoveEnd?: (e: any) => void;
    onZoom?: (e: any) => void;
    onZoomStart?: (e: any) => void;
    onZoomEnd?: (e: any) => void;
    onPitch?: (e: any) => void;
    onPitchStart?: (e: any) => void;
    onPitchEnd?: (e: any) => void;

}
export interface Marker {
    latitude: number;
    longitude: number;
    element?: React.ReactNode;
    offset?: [number, number];
    anchor?: 'top' | 'bottom' | 'left' | 'right';
    draggable?: boolean;
    popUp?: React.ReactNode;


}

Example with markers:

<MapContainer 
  apiKey="YOUR_API_KEY"
  markers={[
    { longitude: 77.61, latitude: 12.93 },
    { longitude: 77.62, latitude: 12.94 },
  ]}
/>

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Thanks to Ola Maps for providing the mapping SDK.
  • This wrapper was inspired by the need for an easy-to-use React component for Ola Maps.

Support

If you encounter any problems or have any questions, please open an issue in the GitHub repository.