An open API service indexing awesome lists of open source software.

https://github.com/allenhwkim/react-openlayers

OpenLayer React Components
https://github.com/allenhwkim/react-openlayers

map openlayers react typescript wrapper

Last synced: 10 months ago
JSON representation

OpenLayer React Components

Awesome Lists containing this project

README

          

# React components for OpenLayers

A minimal React wrapper of [OpenLayers 10](https://openlayers.org/)
written in [TypeScript](https://www.typescriptlang.org/)

![Image](https://github.com/user-attachments/assets/9dfc9102-4952-4c56-a76b-19699a5a4570)

## Install
```
npm install react-openlayers
```

## Example
```typescript
import { OSM } from 'ol/source';
import { Map, View, TileLayer } from 'react-openlayers';
import 'react-openlayers/dist/index.css'; // for css

export default function(props) {
return (




);
}
```

## List of components

### Base
| OpenLayers Object | React Component | Description |
| -------------- | --------------- | ------------ |
| ol/Map | `` | It manages layers, controls, interactions, and the overall rendering of the map. |
| ol/Overlay | ``| It add HTML elements to the map at specific coordinates. |
| ol/View | `` | A View object represents a simple 2D view of the map |
| ol/Feature | `` | ol/Feature customized as a map maker. |

### Layers
| OpenLayers Object | React Component | Description |
| -------------- | --------------- | ------------ |
| ol/layer/Graticule | `` | Displays a graticule (grid of latitude and longitude lines) on the map. |
| ol/layer/Heatmap | `` | Displays a heatmap based on vector data. |
| ol/layer/Tile | `` | Displays tiled images, such as those from a tile server. |
| ol/layer/Vector | `` | Displays vector data, such as points, lines, and polygons. |
| ol/layer/WebGLTile | `` | Displays tiled images using WebGL for rendering. |

### Controls
| OpenLayers Object | React Component | Description |
| -------------- | --------------- | ------------ |
| ol/control/Attribution | `` | Displays attribution information for the map layers |
| ol/control/FullScreen | `` | Adds a button to toggle full-screen mode |
| ol/control/MousePosition | `` | Displays the current mouse position in coordinates |
| ol/control/OverviewMap | `` | Displays an overview map of the main map |
| ol/control/ScaleLine | `` | Displays an overview map of the main map |
| custom | `` | Layer switcher |
| custom | `` | Shape Drawing shapes; point, rectangle, circle, ploygon |
| custom | `` | Search an address and set a marker |

### Interactions
| OpenLayers Object | React Component | Description |
| -------------- | --------------- | ------------ |
| ol/interaction/DragRotateAndZoom| `` | Allows rotating and zooming the map by dragging. |
| ol/interaction/Link | `` | Synchronizes the map view with the URL. |
| ol/interaction/Pointer | `` | Base class for pointer interactions. |
| ol/interaction/Select | `` | Allows selecting features on the map. |
| ol/interaction/Translate | `` | Allows translating (moving) features on the map. |

## For developers

There are two group of sources and corresponding builds.

1. React component library

Code for component library is in `./src/lib` directory.
This is to be published to [npm](https://www.npmjs.com/package/react-openlayers)
after build, `$ npm run build:lib`, which produces output to `./dist` directory

2. Storybook documentation.

Code for Storybook is in `./src/stories`. Storybook documents and
demonstrates the usage of each component. It is deployed to
[Github Pages](https://allenhwkim.github.io/react-openlayers).

When `main` branch is updated, a Github Action runs the build command,
`$ npm run build:storybook`, which writes to `./storybook-static` directory,
and the Github Action deploys the direcory to the Github Pages.