Skip to content

Commit 0b41afc

Browse files
committed
Update docs and demos for image layer usage
1 parent 982eb0c commit 0b41afc

File tree

5 files changed

+109
-10
lines changed

5 files changed

+109
-10
lines changed

README.md

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,103 @@
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`** | [![npm](https://img.shields.io/npm/v/@naivemap/maplibre-gl-echarts-layer.svg)](https://www.npmjs.com/package/@naivemap/maplibre-gl-echarts-layer) | [![license](https://img.shields.io/npm/l/@naivemap/maplibre-gl-echarts-layer.svg)](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`** | [![npm](https://img.shields.io/npm/v/@naivemap/maplibre-gl-image-layer.svg)](https://www.npmjs.com/package/@naivemap/maplibre-gl-image-layer) | [![license](https://img.shields.io/npm/l/@naivemap/maplibre-gl-image-layer.svg)](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.

docs/public/demos/image-27770.html

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1" />
88
<link rel="stylesheet" href="https://unpkg.com/maplibre-gl/dist/maplibre-gl.css" />
99
<script src="https://unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script>
10-
<script src="https://unpkg.com/proj4/dist/proj4.js"></script>
10+
<script src="https://unpkg.com/proj4"></script>
1111
<script src="https://unpkg.com/@naivemap/maplibre-gl-image-layer"></script>
1212
<style>
1313
* {
@@ -34,13 +34,9 @@
3434
const map = new maplibregl.Map({
3535
container: 'map',
3636
style: 'https://www.naivemap.com/demotiles/style.json',
37-
bounds: [
38-
[105.289838, 32.204171],
39-
[110.195632, 28.164713]
40-
],
41-
fitBoundsOptions: {
42-
padding: { top: 10, bottom: 10, left: 10, right: 10 }
43-
}
37+
center: [-5.24, 56.4],
38+
zoom: 3.2,
39+
hash: true
4440
})
4541
map.on('load', () => {
4642
const layer = new ImageLayer('image-layer', {

docs/public/demos/image.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<meta name="viewport" content="width=device-width, initial-scale=1" />
88
<link rel="stylesheet" href="https://unpkg.com/maplibre-gl/dist/maplibre-gl.css" />
99
<script src="https://unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script>
10+
<script src="https://unpkg.com/proj4"></script>
1011
<script src="https://unpkg.com/@naivemap/maplibre-gl-image-layer"></script>
1112
<style>
1213
* {
664 KB
Loading

packages/maplibre-gl-image-layer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ ImageLayer ([@naivemap/maplibre-gl-image-layer](https://www.npmjs.com/package/@n
77
## Install
88

99
```bash
10-
pnpm add @naivemap/maplibre-gl-image-layer
10+
pnpm add @naivemap/maplibre-gl-image-layer proj4
1111
```

0 commit comments

Comments
 (0)