|
1 | | -# vite-lib-template |
| 1 | +# MapLibre GL JS Custom Layers |
| 2 | + |
| 3 | +A collection of custom layer implementations for MapLibre GL JS, designed to extend its visualization capabilities. |
| 4 | + |
| 5 | +**[Live Demos & Documentation](https://naivemap.github.io/maplibre-gl-layers/)** |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Packages |
| 10 | + |
| 11 | +This monorepo contains the following packages: |
| 12 | + |
| 13 | +| Package | NPM Version | License | Description | |
| 14 | +| --- | --- | --- | --- | |
| 15 | +| **`@naivemap/maplibre-gl-echarts-layer`** | [](https://www.npmjs.com/package/@naivemap/maplibre-gl-echarts-layer) | [](https://github.com/naivemap/maplibre-gl-layers/blob/main/LICENSE) | Integrates Apache ECharts (`lines` and `scatter` charts) as a high-performance layer in MapLibre GL JS. | |
| 16 | +| **`@naivemap/maplibre-gl-image-layer`** | [](https://www.npmjs.com/package/@naivemap/maplibre-gl-image-layer) | [](https://github.com/naivemap/maplibre-gl-layers/blob/main/LICENSE) | A versatile layer for displaying georeferenced images with various projections (using `proj4js`) on the map. | |
| 17 | + |
| 18 | +## Getting Started |
| 19 | + |
| 20 | +### Installation |
| 21 | + |
| 22 | +Install the desired package using your favorite package manager: |
| 23 | + |
| 24 | +```bash |
| 25 | +# Install EChartsLayer |
| 26 | +pnpm add @naivemap/maplibre-gl-echarts-layer echarts maplibre-gl |
| 27 | + |
| 28 | +# Install ImageLayer |
| 29 | +pnpm add @naivemap/maplibre-gl-image-layer proj4js maplibre-gl |
| 30 | +``` |
| 31 | + |
| 32 | +### Quick Usage Example (`EChartsLayer`) |
| 33 | + |
| 34 | +Here is a quick example of how to use the `@naivemap/maplibre-gl-echarts-layer`. |
| 35 | + |
| 36 | +```javascript |
| 37 | +import { Map } from 'maplibre-gl' |
| 38 | +import EChartsLayer from '@naivemap/maplibre-gl-echarts-layer' |
| 39 | + |
| 40 | +// 1. Initialize the map |
| 41 | +const map = new Map({ |
| 42 | + container: 'map', |
| 43 | + style: 'https://demotiles.maplibre.org/style.json', |
| 44 | + center: [0, 0], |
| 45 | + zoom: 1 |
| 46 | +}) |
| 47 | + |
| 48 | +// 2. Define your ECharts options |
| 49 | +const option = { |
| 50 | + series: [ |
| 51 | + { |
| 52 | + type: 'scatter', |
| 53 | + name: 'Cities', |
| 54 | + data: [ |
| 55 | + { name: 'New York', value: [-74.006, 40.7128] }, |
| 56 | + { name: 'London', value: [-0.1278, 51.5074] }, |
| 57 | + { name: 'Tokyo', value: [139.6917, 35.6895] } |
| 58 | + ], |
| 59 | + symbolSize: 10 |
| 60 | + } |
| 61 | + ] |
| 62 | +} |
| 63 | + |
| 64 | +// 3. Add the layer to the map |
| 65 | +map.on('load', () => { |
| 66 | + const layer = new EChartsLayer('echarts-layer', option) |
| 67 | + map.addLayer(layer) |
| 68 | +}) |
| 69 | +``` |
| 70 | + |
| 71 | +For more detailed examples and API documentation, please visit our **[documentation site](https://naivemap.github.io/maplibre-gl-layers/)**. |
| 72 | + |
| 73 | +## Development |
| 74 | + |
| 75 | +This project is a monorepo managed by pnpm. |
| 76 | + |
| 77 | +1. **Clone the repository:** |
| 78 | + |
| 79 | + ```bash |
| 80 | + git clone https://github.com/naivemap/maplibre-gl-layers.git |
| 81 | + cd maplibre-gl-layers |
| 82 | + ``` |
| 83 | + |
| 84 | +2. **Install dependencies:** |
| 85 | + |
| 86 | + ```bash |
| 87 | + pnpm install |
| 88 | + ``` |
| 89 | + |
| 90 | +3. **Run the development server for documentation:** This command will build the packages, generate TypeDoc documentation, and start the VitePress development server. |
| 91 | + |
| 92 | + ```bash |
| 93 | + pnpm docs:dev |
| 94 | + ``` |
| 95 | + |
| 96 | +4. **Build all packages:** |
| 97 | + ```bash |
| 98 | + pnpm build |
| 99 | + ``` |
| 100 | + |
| 101 | +## License |
| 102 | + |
| 103 | +This project is licensed under the MIT License - see the [LICENSE](https://github.com/naivemap/maplibre-gl-layers/blob/main/LICENSE) file for details. |
0 commit comments