Skip to content

Commit

Permalink
Review LICENSE README.md CONTRIBUTING.md
Browse files Browse the repository at this point in the history
  • Loading branch information
frodrigo committed Aug 28, 2024
1 parent 9f8fcae commit f5299b6
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 24 deletions.
27 changes: 27 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Contributing

This project was bootstrapped with [TSDX](https://github.com/jaredpalmer/tsdx).

## Local Development

Below is a list of commands you will probably find useful.

### `npm start` or `yarn start`

Runs the project in development/watch mode. Your project will be rebuilt upon changes. TSDX has a special logger for you convenience. Error messages are pretty printed and formatted for compatibility VS Code's Problems tab.

<img src="https://user-images.githubusercontent.com/4060187/52168303-574d3a00-26f6-11e9-9f3b-71dbec9ebfcb.gif" width="600" />

Your library will be rebuilt if you make edits.

### `npm run build` or `yarn build`

Bundles the package to the `dist` folder.
The package is optimized and bundled with Rollup into multiple formats (CommonJS, UMD, and ES Module).

<img src="https://user-images.githubusercontent.com/4060187/52168322-a98e5b00-26f6-11e9-8cf6-222d716b75ef.gif" width="600" />

### `npm test` or `yarn test`

Runs the test watcher (Jest) in an interactive mode.
By default, runs tests related to files changed since the last commit.
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Noé Viricel
Copyright (c) 2024 Teritorio

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
71 changes: 49 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
# maplibre-gl-teritorio-cluster
# MapLibre GL Teritorio Cluster

![alt text](image.png)
Render native MapLibre GL JS clusters as HTML marker. Render:
- HTML cluster
- HTML group marked small cluster or last zoom level

Show cluster's points in one HTML element
Allow to see and interact with all map markers, even when superposed. Allow to see and interact with small cluster without the need to need to zoom or uncluster.

## Installation
See the [Demo page](https://teritorio.github.io/maplibre-gl-teritorio-cluster/index.html).

```bash
npm install maplibre-gl maplibre-gl-teritorio-cluster
```
![alt text](image.png)

## Demo
## Usage

Add to you project (or use CDN).
```bash
yarn install
yarn dev
npm add maplibre-gl-teritorio-cluster
```

## Usage

> [!WARNING]
> [!WARNING]
> Set your GeoJson source with `clusterMaxZoom: 22` in order to let the plugin handle cluster/individual marker rendering.
```js
import { Map } from "maplibre-gl"
import UnCluster from 'maplibre-gl-teritorio-cluster'

const map = new Map({
container: "map_dom_el_id",
zoom: 0.3,
center: [0, 20],
style: 'https://api.maptiler.com/maps/openstreetmap/style.json?key=your_api_key'
container: "map_dom_el_id",
zoom: 0.3,
center: [0, 20],
style: 'https://api.maptiler.com/maps/openstreetmap/style.json?key=your_api_key'
});

// Set `clusterMaxZoom` to force display unclustered points on a certain zoom level
Expand All @@ -39,15 +37,44 @@ const clusterMaxZoom = 17
const unCluster = new UnCluster(map, 'your_cluster_source', { clusterMaxZoom }, createClusterHTML, createSingleMarkerHTML)

map.on('data', (e) => {
if (e.sourceId !== 'your_cluster_source' || !e.isSourceLoaded) return;
if (e.sourceId !== 'your_cluster_source' || !e.isSourceLoaded) return;

map.on('move', unCluster.render);
map.on('moveend', unCluster.render);
unCluster.render()
map.on('move', unCluster.render);
map.on('moveend', unCluster.render);
unCluster.render()
});

// Create whatever HTML element you want as Cluster
const displayCluster = (): HTMLElement => {}
// Create whatever HTML element you want as individual Marker
const displayMarker = (): HTMLElement => {}
```
```

## Dev

Install Maplibre GL JS as peer dependency (be seriously, you should already have it)
```bash
npm install maplibre-gl
```

Install dependencies
```bash
yarn install
```

Serve the demo page
```bash
yarn dev
```

## Requirements

Requires [maplibre-gl-js](https://maplibre.org/projects/#js) >= v4.0.0.

## Contribution

Please see the [contribution guide](CONTRIBUTING.md).

## Author

[Teritorio](https://teritorio.fr)

0 comments on commit f5299b6

Please sign in to comment.