@trapar-waves/react-three-maplibre 1.1.8 → 1.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -54,20 +54,178 @@ npm -v
54
54
 
55
55
  ### Installation
56
56
 
57
- Run script
57
+ 1. Create a new project using the template:
58
58
 
59
59
  ```bash
60
60
  pnpm create trapar-waves
61
61
  ```
62
62
 
63
- Install dependencies
63
+ 2. Navigate to your project directory and install dependencies:
64
64
 
65
65
  ```bash
66
+ cd your-project-name
67
+ pnpm install
68
+ # or
66
69
  npm install
70
+ # or
67
71
  yarn install
68
- pnpm install
69
72
  ```
70
73
 
74
+ ### Development
75
+
76
+ Start the development server with hot reloading:
77
+
78
+ ```bash
79
+ pnpm dev
80
+ # or
81
+ npm run dev
82
+ # or
83
+ yarn dev
84
+ ```
85
+
86
+ The application will be available at `http://localhost:3000` by default.
87
+
88
+ ### Building for Production
89
+
90
+ To create a production build:
91
+
92
+ ```bash
93
+ pnpm build
94
+ # or
95
+ npm run build
96
+ # or
97
+ yarn build
98
+ ```
99
+
100
+ Preview the production build locally:
101
+
102
+ ```bash
103
+ pnpm preview
104
+ # or
105
+ npm run preview
106
+ # or
107
+ yarn preview
108
+ ```
109
+
110
+ ## 📦 Usage
111
+
112
+ This library is designed to be used as a template for creating geospatial 3D visualization applications. It provides a foundational setup with React, Three.js, MapLibre GL, and AntV L7.
113
+
114
+ ### Basic Example
115
+
116
+ Here's a simple example of how to use the components provided by this template:
117
+
118
+ ```tsx
119
+ // App.tsx
120
+ import type { ReactNode } from "react";
121
+ import type { MapRef } from "react-map-gl/maplibre";
122
+ import { PointLayer, Scene } from "@antv/l7";
123
+ import { MapLibre } from "@antv/l7-maps";
124
+ import { Box, Stats } from "@react-three/drei";
125
+ import { extend } from "@react-three/fiber";
126
+ import { useRef } from "react";
127
+ import Map from "react-map-gl/maplibre";
128
+ import { Canvas } from "react-three-map/maplibre";
129
+ import { LineMaterial, LineSegments2, LineSegmentsGeometry } from "three-stdlib";
130
+
131
+ extend({ LineSegmentsGeometry, LineMaterial, LineSegments2 });
132
+
133
+ declare module "@react-three/fiber" {
134
+ interface ThreeElements {
135
+ lineSegmentsGeometry: ThreeElements["bufferGeometry"];
136
+ lineMaterial: ThreeElements["material"] & Partial<LineMaterial>;
137
+ lineSegments2: ThreeElements["object3D"] & { children?: ReactNode };
138
+ }
139
+ }
140
+
141
+ const latLon = {
142
+ latitude: 31.215175,
143
+ longitude: 121.417463,
144
+ };
145
+ const MAPTILER_KEY = import.meta.env.PUBLIC_MAPTILER_KEY;
146
+
147
+ function App() {
148
+ const ref = useRef<HTMLDivElement>(null!);
149
+ const mapRef = useRef<MapRef>(null!);
150
+ function initL7() {
151
+ if (mapRef.current) {
152
+ const scene = new Scene({
153
+ id: "map",
154
+ map: new MapLibre({
155
+ mapInstance: mapRef.current.getMap(),
156
+ }),
157
+ });
158
+ scene.on("loaded", () => {
159
+ fetch("/BElVQFEFvpAKzddxFZxJ.txt")
160
+ .then(res => res.text())
161
+ .then((data) => {
162
+ const pointLayer = new PointLayer({
163
+ blend: "additive",
164
+ })
165
+ .source(data, {
166
+ parser: {
167
+ type: "csv",
168
+ y: "lat",
169
+ x: "lng",
170
+ },
171
+ })
172
+ .size(0.5)
173
+ .color("#080298");
174
+
175
+ scene.addLayer(pointLayer);
176
+ });
177
+ });
178
+ }
179
+ }
180
+ return (
181
+ <div className="h-screen w-screen relative overflow-hidden" ref={ref}>
182
+ <Map
183
+ id="map"
184
+ ref={mapRef}
185
+ initialViewState={{
186
+ ...latLon,
187
+ zoom: 11,
188
+ pitch: 64.88,
189
+ }}
190
+ mapStyle={`https://api.maptiler.com/maps/streets/style.json?key=${MAPTILER_KEY}`}
191
+ onLoad={initL7}
192
+ >
193
+ <Stats className="stats" parent={ref} />
194
+
195
+ <Canvas {...latLon}>
196
+ <hemisphereLight
197
+ args={["#ffffff", "#60666C"]}
198
+ position={[1, 4.5, 3]}
199
+ />
200
+ <object3D scale={500}>
201
+ <Box position={[-1.2, 1, 0]} />
202
+ <Box position={[1.2, 1, 0]} />
203
+ </object3D>
204
+ </Canvas>
205
+ </Map>
206
+ </div>
207
+ );
208
+ }
209
+
210
+ export default App;
211
+ ```
212
+
213
+ This example demonstrates:
214
+ - Creating a MapLibre GL map with `react-map-gl`
215
+ - Integrating AntV L7 for geospatial data visualization
216
+ - Using React Three Fiber and Drei for 3D rendering
217
+ - Positioning 3D objects relative to the map using `react-three-map`
218
+
219
+ ### Environment Variables
220
+
221
+ To use map services like MapTiler, you'll need to set up environment variables. Create a `.env` file in your project root:
222
+
223
+ ```
224
+ PUBLIC_MAPTILER_KEY=your_maptiler_api_key_here
225
+ ```
226
+
227
+ Make sure to add `.env` to your `.gitignore` to keep your keys secure.
228
+
71
229
  ## 🤝 Contributing
72
230
 
73
231
  Contributions are welcome and greatly appreciated! Please follow these steps to contribute:
@@ -78,6 +236,8 @@ Contributions are welcome and greatly appreciated! Please follow these steps to
78
236
  4. Push to the branch (`git push origin feature/amazing-feature`)
79
237
  5. Open a Pull Request
80
238
 
239
+ Please ensure your code follows the existing style and passes all tests.
240
+
81
241
  ## 👤 Author
82
242
 
83
243
  - **Rikka:** (admin@rikka.cc)
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@trapar-waves/react-three-maplibre",
3
3
  "type": "module",
4
- "version": "1.1.8",
5
- "packageManager": "pnpm@10.14.0",
4
+ "version": "1.1.10",
5
+ "packageManager": "pnpm@10.15.0",
6
6
  "description": "A React library integrating Three.js and MapLibre for 3D map visualization",
7
7
  "author": {
8
8
  "email": "admin@rikka.cc",
@@ -40,9 +40,9 @@
40
40
  "dependencies": {
41
41
  "@antv/l7": "^2.23.0",
42
42
  "@antv/l7-maps": "^2.23.0",
43
- "@react-three/drei": "^10.7.3",
43
+ "@react-three/drei": "^10.7.4",
44
44
  "@react-three/fiber": "^9.3.0",
45
- "maplibre-gl": "^5.6.2",
45
+ "maplibre-gl": "^5.7.0",
46
46
  "react": "^19.1.1",
47
47
  "react-dom": "^19.1.1",
48
48
  "react-map-gl": "^8.0.4",
@@ -52,16 +52,16 @@
52
52
  },
53
53
  "devDependencies": {
54
54
  "@antfu/eslint-config": "^5.2.1",
55
- "@eslint-react/eslint-plugin": "^1.52.5",
56
- "@iconify/json": "^2.2.375",
55
+ "@eslint-react/eslint-plugin": "^1.52.9",
56
+ "@iconify/json": "^2.2.380",
57
57
  "@iconify/tailwind4": "^1.0.6",
58
- "@rsbuild/core": "^1.4.15",
59
- "@rsbuild/plugin-react": "^1.3.5",
58
+ "@rsbuild/core": "^1.5.2",
59
+ "@rsbuild/plugin-react": "^1.4.0",
60
60
  "@tailwindcss/postcss": "^4.1.12",
61
- "@types/react": "^19.1.10",
62
- "@types/react-dom": "^19.1.7",
61
+ "@types/react": "^19.1.12",
62
+ "@types/react-dom": "^19.1.9",
63
63
  "@types/three": "^0.179.0",
64
- "eslint": "^9.33.0",
64
+ "eslint": "^9.34.0",
65
65
  "eslint-plugin-format": "^1.0.1",
66
66
  "eslint-plugin-react-hooks": "^5.2.0",
67
67
  "eslint-plugin-react-refresh": "^0.4.20",
@@ -54,20 +54,178 @@ npm -v
54
54
 
55
55
  ### 安装步骤
56
56
 
57
- 运行脚本
57
+ 1. 使用模板创建新项目:
58
58
 
59
59
  ```bash
60
60
  pnpm create trapar-waves
61
61
  ```
62
62
 
63
- 安装依赖
63
+ 2. 进入项目目录并安装依赖:
64
64
 
65
65
  ```bash
66
+ cd your-project-name
67
+ pnpm install
68
+ # or
66
69
  npm install
70
+ # or
67
71
  yarn install
68
- pnpm install
69
72
  ```
70
73
 
74
+ ### 开发
75
+
76
+ 启动带热重载的开发服务器:
77
+
78
+ ```bash
79
+ pnpm dev
80
+ # or
81
+ npm run dev
82
+ # or
83
+ yarn dev
84
+ ```
85
+
86
+ 默认情况下,应用程序将在 `http://localhost:3000` 可用。
87
+
88
+ ### 构建生产版本
89
+
90
+ 创建生产构建:
91
+
92
+ ```bash
93
+ pnpm build
94
+ # or
95
+ npm run build
96
+ # or
97
+ yarn build
98
+ ```
99
+
100
+ 在本地预览生产构建:
101
+
102
+ ```bash
103
+ pnpm preview
104
+ # or
105
+ npm run preview
106
+ # or
107
+ yarn preview
108
+ ```
109
+
110
+ ## 📦 使用方法
111
+
112
+ 该库被设计为用于创建地理空间3D可视化应用程序的模板。它提供了一个基础设置,包括 React、Three.js、MapLibre GL 和 AntV L7。
113
+
114
+ ### 基本示例
115
+
116
+ 以下是一个如何使用此模板提供的组件的简单示例:
117
+
118
+ ```tsx
119
+ // App.tsx
120
+ import type { ReactNode } from "react";
121
+ import type { MapRef } from "react-map-gl/maplibre";
122
+ import { PointLayer, Scene } from "@antv/l7";
123
+ import { MapLibre } from "@antv/l7-maps";
124
+ import { Box, Stats } from "@react-three/drei";
125
+ import { extend } from "@react-three/fiber";
126
+ import { useRef } from "react";
127
+ import Map from "react-map-gl/maplibre";
128
+ import { Canvas } from "react-three-map/maplibre";
129
+ import { LineMaterial, LineSegments2, LineSegmentsGeometry } from "three-stdlib";
130
+
131
+ extend({ LineSegmentsGeometry, LineMaterial, LineSegments2 });
132
+
133
+ declare module "@react-three/fiber" {
134
+ interface ThreeElements {
135
+ lineSegmentsGeometry: ThreeElements["bufferGeometry"];
136
+ lineMaterial: ThreeElements["material"] & Partial<LineMaterial>;
137
+ lineSegments2: ThreeElements["object3D"] & { children?: ReactNode };
138
+ }
139
+ }
140
+
141
+ const latLon = {
142
+ latitude: 31.215175,
143
+ longitude: 121.417463,
144
+ };
145
+ const MAPTILER_KEY = import.meta.env.PUBLIC_MAPTILER_KEY;
146
+
147
+ function App() {
148
+ const ref = useRef<HTMLDivElement>(null!);
149
+ const mapRef = useRef<MapRef>(null!);
150
+ function initL7() {
151
+ if (mapRef.current) {
152
+ const scene = new Scene({
153
+ id: "map",
154
+ map: new MapLibre({
155
+ mapInstance: mapRef.current.getMap(),
156
+ }),
157
+ });
158
+ scene.on("loaded", () => {
159
+ fetch("/BElVQFEFvpAKzddxFZxJ.txt")
160
+ .then(res => res.text())
161
+ .then((data) => {
162
+ const pointLayer = new PointLayer({
163
+ blend: "additive",
164
+ })
165
+ .source(data, {
166
+ parser: {
167
+ type: "csv",
168
+ y: "lat",
169
+ x: "lng",
170
+ },
171
+ })
172
+ .size(0.5)
173
+ .color("#080298");
174
+
175
+ scene.addLayer(pointLayer);
176
+ });
177
+ });
178
+ }
179
+ }
180
+ return (
181
+ <div className="h-screen w-screen relative overflow-hidden" ref={ref}>
182
+ <Map
183
+ id="map"
184
+ ref={mapRef}
185
+ initialViewState={{
186
+ ...latLon,
187
+ zoom: 11,
188
+ pitch: 64.88,
189
+ }}
190
+ mapStyle={`https://api.maptiler.com/maps/streets/style.json?key=${MAPTILER_KEY}`}
191
+ onLoad={initL7}
192
+ >
193
+ <Stats className="stats" parent={ref} />
194
+
195
+ <Canvas {...latLon}>
196
+ <hemisphereLight
197
+ args={["#ffffff", "#60666C"]}
198
+ position={[1, 4.5, 3]}
199
+ />
200
+ <object3D scale={500}>
201
+ <Box position={[-1.2, 1, 0]} />
202
+ <Box position={[1.2, 1, 0]} />
203
+ </object3D>
204
+ </Canvas>
205
+ </Map>
206
+ </div>
207
+ );
208
+ }
209
+
210
+ export default App;
211
+ ```
212
+
213
+ 这个示例演示了:
214
+ - 使用 `react-map-gl` 创建 MapLibre GL 地图
215
+ - 集成 AntV L7 进行地理空间数据可视化
216
+ - 使用 React Three Fiber 和 Drei 进行 3D 渲染
217
+ - 使用 `react-three-map` 将 3D 对象相对于地图进行定位
218
+
219
+ ### 环境变量
220
+
221
+ 要使用 MapTiler 等地图服务,您需要设置环境变量。在项目根目录创建一个 `.env` 文件:
222
+
223
+ ```
224
+ PUBLIC_MAPTILER_KEY=your_maptiler_api_key_here
225
+ ```
226
+
227
+ 确保将 `.env` 添加到 `.gitignore` 中以保证密钥安全。
228
+
71
229
  ## 🤝 贡献指南
72
230
 
73
231
  欢迎贡献,非常感谢您的支持!请按照以下步骤进行贡献:
@@ -78,6 +236,8 @@ pnpm install
78
236
  4. 推送到分支(`git push origin feature/amazing-feature`)
79
237
  5. 打开Pull Request
80
238
 
239
+ 请确保您的代码遵循现有风格并通过所有测试。
240
+
81
241
  ## 👤 Author
82
242
 
83
243
  - **Rikka:** (admin@rikka.cc)
@@ -54,20 +54,178 @@ npm -v
54
54
 
55
55
  ### インストール
56
56
 
57
- スクリプトの実行
57
+ 1. テンプレートを使用して新しいプロジェクトを作成します:
58
58
 
59
59
  ```bash
60
60
  pnpm create trapar-waves
61
61
  ```
62
62
 
63
- 依存関係のインストール
63
+ 2. プロジェクトディレクトリに移動し、依存関係をインストールします:
64
64
 
65
65
  ```bash
66
+ cd your-project-name
67
+ pnpm install
68
+ # or
66
69
  npm install
70
+ # or
67
71
  yarn install
68
- pnpm install
69
72
  ```
70
73
 
74
+ ### 開発
75
+
76
+ ホットリロード付きの開発サーバーを起動します:
77
+
78
+ ```bash
79
+ pnpm dev
80
+ # or
81
+ npm run dev
82
+ # or
83
+ yarn dev
84
+ ```
85
+
86
+ アプリケーションはデフォルトで `http://localhost:3000` で利用可能です。
87
+
88
+ ### 本番用ビルド
89
+
90
+ 本番用のビルドを作成します:
91
+
92
+ ```bash
93
+ pnpm build
94
+ # or
95
+ npm run build
96
+ # or
97
+ yarn build
98
+ ```
99
+
100
+ ローカルで本番ビルドをプレビューします:
101
+
102
+ ```bash
103
+ pnpm preview
104
+ # or
105
+ npm run preview
106
+ # or
107
+ yarn preview
108
+ ```
109
+
110
+ ## 📦 使用方法
111
+
112
+ このライブラリは、地理空間3D可視化アプリケーションを作成するためのテンプレートとして設計されています。React、Three.js、MapLibre GL、AntV L7を使用した基本的なセットアップを提供します。
113
+
114
+ ### 基本的な例
115
+
116
+ このテンプレートが提供するコンポーネントの使用方法の簡単な例を以下に示します:
117
+
118
+ ```tsx
119
+ // App.tsx
120
+ import type { ReactNode } from "react";
121
+ import type { MapRef } from "react-map-gl/maplibre";
122
+ import { PointLayer, Scene } from "@antv/l7";
123
+ import { MapLibre } from "@antv/l7-maps";
124
+ import { Box, Stats } from "@react-three/drei";
125
+ import { extend } from "@react-three/fiber";
126
+ import { useRef } from "react";
127
+ import Map from "react-map-gl/maplibre";
128
+ import { Canvas } from "react-three-map/maplibre";
129
+ import { LineMaterial, LineSegments2, LineSegmentsGeometry } from "three-stdlib";
130
+
131
+ extend({ LineSegmentsGeometry, LineMaterial, LineSegments2 });
132
+
133
+ declare module "@react-three/fiber" {
134
+ interface ThreeElements {
135
+ lineSegmentsGeometry: ThreeElements["bufferGeometry"];
136
+ lineMaterial: ThreeElements["material"] & Partial<LineMaterial>;
137
+ lineSegments2: ThreeElements["object3D"] & { children?: ReactNode };
138
+ }
139
+ }
140
+
141
+ const latLon = {
142
+ latitude: 31.215175,
143
+ longitude: 121.417463,
144
+ };
145
+ const MAPTILER_KEY = import.meta.env.PUBLIC_MAPTILER_KEY;
146
+
147
+ function App() {
148
+ const ref = useRef<HTMLDivElement>(null!);
149
+ const mapRef = useRef<MapRef>(null!);
150
+ function initL7() {
151
+ if (mapRef.current) {
152
+ const scene = new Scene({
153
+ id: "map",
154
+ map: new MapLibre({
155
+ mapInstance: mapRef.current.getMap(),
156
+ }),
157
+ });
158
+ scene.on("loaded", () => {
159
+ fetch("/BElVQFEFvpAKzddxFZxJ.txt")
160
+ .then(res => res.text())
161
+ .then((data) => {
162
+ const pointLayer = new PointLayer({
163
+ blend: "additive",
164
+ })
165
+ .source(data, {
166
+ parser: {
167
+ type: "csv",
168
+ y: "lat",
169
+ x: "lng",
170
+ },
171
+ })
172
+ .size(0.5)
173
+ .color("#080298");
174
+
175
+ scene.addLayer(pointLayer);
176
+ });
177
+ });
178
+ }
179
+ }
180
+ return (
181
+ <div className="h-screen w-screen relative overflow-hidden" ref={ref}>
182
+ <Map
183
+ id="map"
184
+ ref={mapRef}
185
+ initialViewState={{
186
+ ...latLon,
187
+ zoom: 11,
188
+ pitch: 64.88,
189
+ }}
190
+ mapStyle={`https://api.maptiler.com/maps/streets/style.json?key=${MAPTILER_KEY}`}
191
+ onLoad={initL7}
192
+ >
193
+ <Stats className="stats" parent={ref} />
194
+
195
+ <Canvas {...latLon}>
196
+ <hemisphereLight
197
+ args={["#ffffff", "#60666C"]}
198
+ position={[1, 4.5, 3]}
199
+ />
200
+ <object3D scale={500}>
201
+ <Box position={[-1.2, 1, 0]} />
202
+ <Box position={[1.2, 1, 0]} />
203
+ </object3D>
204
+ </Canvas>
205
+ </Map>
206
+ </div>
207
+ );
208
+ }
209
+
210
+ export default App;
211
+ ```
212
+
213
+ この例では以下を示しています:
214
+ - `react-map-gl` を使用して MapLibre GL マップを作成する
215
+ - 地理空間データの可視化のために AntV L7 を統合する
216
+ - 3D レンダリングのために React Three Fiber と Drei を使用する
217
+ - `react-three-map` を使用して 3D オブジェクトをマップに対して配置する
218
+
219
+ ### 環境変数
220
+
221
+ MapTiler などのマップサービスを使用するには、環境変数を設定する必要があります。プロジェクトのルートに `.env` ファイルを作成します:
222
+
223
+ ```
224
+ PUBLIC_MAPTILER_KEY=your_maptiler_api_key_here
225
+ ```
226
+
227
+ キーを安全に保つために、`.env` を `.gitignore` に追加してください。
228
+
71
229
  ## 🤝 コントリビューション
72
230
 
73
231
  貢献は歓迎され、非常に高く評価されています!貢献するには以下の手順に従ってください:
@@ -78,6 +236,8 @@ pnpm install
78
236
  4. ブランチにプッシュする(`git push origin feature/amazing-feature`)
79
237
  5. Pull Requestを開く
80
238
 
239
+ コードが既存のスタイルに従い、すべてのテストに合格することを確認してください。
240
+
81
241
  ## 👤 Author
82
242
 
83
243
  - **Rikka:** (admin@rikka.cc)
@@ -54,20 +54,178 @@ npm -v
54
54
 
55
55
  ### Установка
56
56
 
57
- Запустить скрипт
57
+ 1. Создайте новый проект с помощью шаблона:
58
58
 
59
59
  ```bash
60
60
  pnpm create trapar-waves
61
61
  ```
62
62
 
63
- Установить зависимости
63
+ 2. Перейдите в каталог вашего проекта и установите зависимости:
64
64
 
65
65
  ```bash
66
+ cd your-project-name
67
+ pnpm install
68
+ # or
66
69
  npm install
70
+ # or
67
71
  yarn install
68
- pnpm install
69
72
  ```
70
73
 
74
+ ### Разработка
75
+
76
+ Запустите сервер разработки с горячей перезагрузкой:
77
+
78
+ ```bash
79
+ pnpm dev
80
+ # or
81
+ npm run dev
82
+ # or
83
+ yarn dev
84
+ ```
85
+
86
+ Приложение будет доступно по адресу `http://localhost:3000` по умолчанию.
87
+
88
+ ### Сборка для продакшена
89
+
90
+ Чтобы создать сборку для продакшена:
91
+
92
+ ```bash
93
+ pnpm build
94
+ # or
95
+ npm run build
96
+ # or
97
+ yarn build
98
+ ```
99
+
100
+ Предварительный просмотр сборки продакшена локально:
101
+
102
+ ```bash
103
+ pnpm preview
104
+ # or
105
+ npm run preview
106
+ # or
107
+ yarn preview
108
+ ```
109
+
110
+ ## 📦 Использование
111
+
112
+ Эта библиотека предназначена для использования в качестве шаблона для создания приложений геопространственной 3D-визуализации. Она предоставляет фундаментальную настройку с React, Three.js, MapLibre GL и AntV L7.
113
+
114
+ ### Базовый пример
115
+
116
+ Вот простой пример того, как использовать компоненты, предоставляемые этим шаблоном:
117
+
118
+ ```tsx
119
+ // App.tsx
120
+ import type { ReactNode } from "react";
121
+ import type { MapRef } from "react-map-gl/maplibre";
122
+ import { PointLayer, Scene } from "@antv/l7";
123
+ import { MapLibre } from "@antv/l7-maps";
124
+ import { Box, Stats } from "@react-three/drei";
125
+ import { extend } from "@react-three/fiber";
126
+ import { useRef } from "react";
127
+ import Map from "react-map-gl/maplibre";
128
+ import { Canvas } from "react-three-map/maplibre";
129
+ import { LineMaterial, LineSegments2, LineSegmentsGeometry } from "three-stdlib";
130
+
131
+ extend({ LineSegmentsGeometry, LineMaterial, LineSegments2 });
132
+
133
+ declare module "@react-three/fiber" {
134
+ interface ThreeElements {
135
+ lineSegmentsGeometry: ThreeElements["bufferGeometry"];
136
+ lineMaterial: ThreeElements["material"] & Partial<LineMaterial>;
137
+ lineSegments2: ThreeElements["object3D"] & { children?: ReactNode };
138
+ }
139
+ }
140
+
141
+ const latLon = {
142
+ latitude: 31.215175,
143
+ longitude: 121.417463,
144
+ };
145
+ const MAPTILER_KEY = import.meta.env.PUBLIC_MAPTILER_KEY;
146
+
147
+ function App() {
148
+ const ref = useRef<HTMLDivElement>(null!);
149
+ const mapRef = useRef<MapRef>(null!);
150
+ function initL7() {
151
+ if (mapRef.current) {
152
+ const scene = new Scene({
153
+ id: "map",
154
+ map: new MapLibre({
155
+ mapInstance: mapRef.current.getMap(),
156
+ }),
157
+ });
158
+ scene.on("loaded", () => {
159
+ fetch("/BElVQFEFvpAKzddxFZxJ.txt")
160
+ .then(res => res.text())
161
+ .then((data) => {
162
+ const pointLayer = new PointLayer({
163
+ blend: "additive",
164
+ })
165
+ .source(data, {
166
+ parser: {
167
+ type: "csv",
168
+ y: "lat",
169
+ x: "lng",
170
+ },
171
+ })
172
+ .size(0.5)
173
+ .color("#080298");
174
+
175
+ scene.addLayer(pointLayer);
176
+ });
177
+ });
178
+ }
179
+ }
180
+ return (
181
+ <div className="h-screen w-screen relative overflow-hidden" ref={ref}>
182
+ <Map
183
+ id="map"
184
+ ref={mapRef}
185
+ initialViewState={{
186
+ ...latLon,
187
+ zoom: 11,
188
+ pitch: 64.88,
189
+ }}
190
+ mapStyle={`https://api.maptiler.com/maps/streets/style.json?key=${MAPTILER_KEY}`}
191
+ onLoad={initL7}
192
+ >
193
+ <Stats className="stats" parent={ref} />
194
+
195
+ <Canvas {...latLon}>
196
+ <hemisphereLight
197
+ args={["#ffffff", "#60666C"]}
198
+ position={[1, 4.5, 3]}
199
+ />
200
+ <object3D scale={500}>
201
+ <Box position={[-1.2, 1, 0]} />
202
+ <Box position={[1.2, 1, 0]} />
203
+ </object3D>
204
+ </Canvas>
205
+ </Map>
206
+ </div>
207
+ );
208
+ }
209
+
210
+ export default App;
211
+ ```
212
+
213
+ Этот пример демонстрирует:
214
+ - Создание карты MapLibre GL с помощью `react-map-gl`
215
+ - Интеграция AntV L7 для визуализации геопространственных данных
216
+ - Использование React Three Fiber и Drei для 3D-рендеринга
217
+ - Позиционирование 3D-объектов относительно карты с помощью `react-three-map`
218
+
219
+ ### Переменные окружения
220
+
221
+ Для использования сервисов карт, таких как MapTiler, вам нужно настроить переменные окружения. Создайте файл `.env` в корне вашего проекта:
222
+
223
+ ```
224
+ PUBLIC_MAPTILER_KEY=your_maptiler_api_key_here
225
+ ```
226
+
227
+ Обязательно добавьте `.env` в ваш `.gitignore`, чтобы ваши ключи оставались в безопасности.
228
+
71
229
  ## 🤝 Участие в разработке
72
230
 
73
231
  Вклад в проект приветствуется и очень ценится! Чтобы внести вклад, следуйте этим шагам:
@@ -78,6 +236,8 @@ pnpm install
78
236
  4. Отправьте изменения в ветку (`git push origin feature/amazing-feature`)
79
237
  5. Откройте Pull Request
80
238
 
239
+ Пожалуйста, убедитесь, что ваш код соответствует существующему стилю и проходит все тесты.
240
+
81
241
  ## 👤 Author
82
242
 
83
243
  - **Rikka:** (admin@rikka.cc)