@earthview/core 0.1.1 → 0.2.1

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.
Files changed (5) hide show
  1. package/README.md +311 -0
  2. package/dist/index.d.ts +399 -110
  3. package/dist/index.js +925 -136
  4. package/dist/index.mjs +33679 -27165
  5. package/package.json +2 -2
package/README.md CHANGED
@@ -4,6 +4,317 @@
4
4
  <h4 align="center">
5
5
  A reliable geographic information graphics system developed based on OpenLayers.
6
6
  </h4>
7
+ <p align="center">
8
+ <a href="https://github.com/0xhappyboy/earthview/blob/main/LICENSE"><img src="https://img.shields.io/badge/License-AGPL3.0-d1d1f6.svg?style=flat&labelColor=1C2C2E&color=BEC5C9&logo=googledocs&label=license&logoColor=BEC5C9" alt="License"></a>
9
+ <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-5.0+-3178C6.svg?style=flat&labelColor=1C2C2E&color=007ACC&logo=typescript&logoColor=white" alt="TypeScript"></a>
10
+ <a href="https://github.com/0xhappyboy/earthview/stargazers"><img src="https://img.shields.io/github/stars/0xhappyboy/earthview.svg?style=flat&labelColor=1C2C2E&color=FFD700&logo=github&logoColor=white&label=stars" alt="GitHub stars"></a>
11
+ <a href="https://github.com/0xhappyboy/earthview/issues"><img src="https://img.shields.io/github/issues/0xhappyboy/earthview.svg?style=flat&labelColor=1C2C2E&color=FF6B6B&logo=github&logoColor=white&label=issues" alt="GitHub issues"></a>
12
+ <a href="https://github.com/0xhappyboy/earthview/network/members"><img src="https://img.shields.io/github/forks/0xhappyboy/earthview.svg?style=flat&labelColor=1C2C2E&color=42A5F5&logo=github&logoColor=white&label=forks" alt="GitHub forks"></a>
13
+ <a href="https://www.npmjs.com/package/@earthview/core"><img src="https://img.shields.io/npm/v/@earthview/core.svg?style=flat&labelColor=1C2C2E&color=FF5722&logo=npm&logoColor=white&label=npm%20version" alt="npm version"></a>
14
+ <a href="https://github.com/0xhappyboy/earthview/releases"><img src="https://img.shields.io/github/v/tag/0xhappyboy/earthview.svg?style=flat&labelColor=1C2C2E&color=9C27B0&logo=github&logoColor=white&label=latest%20release" alt="GitHub release"></a>
15
+ <a href="https://github.com/0xhappyboy/earthview/actions"><img src="https://img.shields.io/github/actions/workflow/status/0xhappyboy/earthview/release.yml?style=flat&labelColor=1C2C2E&color=4CAF50&logo=githubactions&logoColor=white&label=build" alt="Build Status"></a>
16
+ <a href="https://www.npmjs.com/package/@earthview/core"><img src="https://img.shields.io/npm/dt/@earthview/core?style=flat&labelColor=1C2C2E&color=00BCD4&logo=npm&logoColor=white&label=total%20downloads" alt="npm downloads"></a>
17
+ <a href="https://www.npmjs.com/package/@earthview/core"><img src="https://img.shields.io/npm/dm/@earthview/core?style=flat&labelColor=1C2C2E&color=00BCD4&logo=npm&logoColor=white&label=downloads/month" alt="npm downloads"></a>
18
+ <a href="https://www.npmjs.com/package/@earthview/core"><img src="https://img.shields.io/npm/dw/@earthview/core?style=flat&labelColor=1C2C2E&color=00BCD4&logo=npm&logoColor=white&label=downloads/week" alt="npm downloads"></a>
19
+ </p>
7
20
  <p align="center">
8
21
  <a href="./README_zh-CN.md">简体中文</a> | <a href="./README.md">English</a>
9
22
  </p>
23
+
24
+ ## ⚙️ Install
25
+
26
+ ```bash
27
+ npm i @candleview/core
28
+ ```
29
+
30
+ ```bash
31
+ yarn add @candleview/core
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ```typescript
37
+ // 1. Create with container element
38
+ const earth = new EarthView({ container: document.getElementById("map") });
39
+ // 2. Create with container selector
40
+ const earth = new EarthView({ containerSelector: "#map" });
41
+ // 3. Create with element ID
42
+ const earth = new EarthView({ id: "map" });
43
+ // 4. Create with parent element (auto-creates container)
44
+ const earth = new EarthView({ parent: document.getElementById("wrapper") });
45
+ // 5. Create with parent selector (auto-creates container)
46
+ const earth = new EarthView({ parentSelector: "#wrapper" });
47
+ ```
48
+
49
+ ### Basic Configuration
50
+
51
+ ```typescript
52
+ const earth = new EarthView({
53
+ container: document.getElementById("map"),
54
+ basemap: BasemapTypeEnum.SATELLITE, // Satellite map
55
+ center: [-74.006, 40.7128], // Center point [longitude, latitude]
56
+ zoom: 12, // Zoom level
57
+ coordinateSystem: CoordinateSystemTypeEnum.WGS84,
58
+ theme: "dark", // Theme: "dark" | "light"
59
+ i18n: "en", // Language: "en" | "zh"
60
+ enableDrawing: true, // Enable drawing
61
+ onLoad: (core) => {
62
+ console.log("Map loaded");
63
+ },
64
+ onMoveEnd: (center, zoom) => {
65
+ console.log(center, zoom);
66
+ },
67
+ onMapClick: (event) => {
68
+ console.log(event.longitude, event.latitude);
69
+ },
70
+ });
71
+ ```
72
+
73
+ ### JavaScript
74
+
75
+ ```typescript
76
+ const container = document.getElementById("map");
77
+ const earth = new EarthView({
78
+ container,
79
+ basemap: BasemapTypeEnum.SATELLITE,
80
+ center: [-74.006, 40.7128],
81
+ zoom: 12,
82
+ theme: "dark",
83
+ onLoad: (core) => {
84
+ console.log("Map loaded");
85
+ },
86
+ });
87
+ ```
88
+
89
+ ### React
90
+
91
+ ```typescript
92
+ import { useEffect, useRef } from "react";
93
+ import { EarthView, BasemapTypeEnum } from "./earthview-2/core";
94
+
95
+ const MapComponent = () => {
96
+ const containerRef = useRef<HTMLDivElement>(null);
97
+ const earthRef = useRef<EarthView | null>(null);
98
+
99
+ useEffect(() => {
100
+ if (containerRef.current && !earthRef.current) {
101
+ earthRef.current = new EarthView({
102
+ container: containerRef.current,
103
+ basemap: BasemapTypeEnum.SATELLITE,
104
+ center: [-74.006, 40.7128],
105
+ zoom: 12
106
+ });
107
+ }
108
+ return () => earthRef.current?.destroy();
109
+ }, []);
110
+
111
+ return <div ref={containerRef} style={{ width: "100%", height: "500px" }} />;
112
+ };
113
+ ```
114
+
115
+ ### Vue3
116
+
117
+ ```typescript
118
+ <template>
119
+ <div ref="containerRef" style="width:100%;height:500px"></div>
120
+ </template>
121
+
122
+ <script setup lang="ts">
123
+ import { ref, onMounted, onUnmounted } from "vue";
124
+ import { EarthView, BasemapTypeEnum } from "./earthview-2/core";
125
+
126
+ const containerRef = ref<HTMLDivElement | null>(null);
127
+ let earth: EarthView | null = null;
128
+
129
+ onMounted(() => {
130
+ if (containerRef.value) {
131
+ earth = new EarthView({
132
+ container: containerRef.value,
133
+ basemap: BasemapTypeEnum.SATELLITE,
134
+ center: [-74.006, 40.7128],
135
+ zoom: 12
136
+ });
137
+ }
138
+ });
139
+
140
+ onUnmounted(() => earth?.destroy());
141
+ </script>
142
+ ```
143
+
144
+ ### Vue2
145
+
146
+ ```typescript
147
+ <template>
148
+ <div ref="container" style="width:100%;height:500px"></div>
149
+ </template>
150
+
151
+ <script>
152
+ import { EarthView, BasemapTypeEnum } from "./earthview-2/core";
153
+
154
+ export default {
155
+ mounted() {
156
+ this.earth = new EarthView({
157
+ container: this.$refs.container,
158
+ basemap: BasemapTypeEnum.SATELLITE,
159
+ center: [-74.006, 40.7128],
160
+ zoom: 12
161
+ });
162
+ },
163
+ beforeDestroy() {
164
+ this.earth?.destroy();
165
+ }
166
+ };
167
+ </script>
168
+ ```
169
+
170
+ ## MarkLayer
171
+
172
+ ### Example
173
+
174
+ ```typescript
175
+ import {
176
+ EarthView,
177
+ MarkerLayer,
178
+ MarkerLayerPointTypeEnum,
179
+ } from "@earthview/core";
180
+ // Create map
181
+ const earth = new EarthView({
182
+ container: document.getElementById("map"),
183
+ center: [-74.006, 40.7128], // New York
184
+ zoom: 12,
185
+ });
186
+ // Create marker layer
187
+ const markerLayer = new MarkerLayer("my-markers", "My Markers", {
188
+ defaultColor: [255, 99, 71, 1], // Default color (red)
189
+ defaultSize: 16, // Default size
190
+ });
191
+ // Add to map
192
+ earth.getLayerManager().addLayer(markerLayer);
193
+ // Add marker
194
+ await markerLayer.addMarker({
195
+ id: "marker_1",
196
+ longitude: -74.006,
197
+ latitude: 40.7128,
198
+ bubbleBoxTitle: "Times Square",
199
+ bubbleBoxDescription: "New York landmark",
200
+ pointType: MarkerLayerPointTypeEnum.CIRCLE,
201
+ pointColor: "rgba(255, 0, 0, 0.8)",
202
+ pointSize: 20,
203
+ onClick: (data, event) => {
204
+ console.log("Clicked:", data.bubbleBoxTitle);
205
+ },
206
+ });
207
+ // Update marker
208
+ await markerLayer.updateMarker("marker_1", {
209
+ pointColor: "rgba(0, 255, 0, 0.8)",
210
+ pointSize: 24,
211
+ });
212
+ // Get all markers
213
+ const allMarkers = markerLayer.getAllMarkers();
214
+ // Remove marker
215
+ markerLayer.removeMarker("marker_1");
216
+ // Clear all markers
217
+ markerLayer.clearAllMarkers();
218
+ ```
219
+
220
+ ### Parameter explanation
221
+
222
+ #### Marker layer data interface
223
+
224
+ ```typescipt
225
+ export interface MarkerLayerData {
226
+ id: string; // Unique identifier (required)
227
+ longitude: number; // Longitude coordinate (required)
228
+ latitude: number; // Latitude coordinate (required)
229
+ bubbleBoxTitle?: string; // Popup title
230
+ bubbleBoxDescription?: string; // Popup description content
231
+ bubbleBoxCoverImage?: string; // Popup cover image URL
232
+ pointColor?: string; // Marker color, format: rgba(255,0,0,0.8)
233
+ pointType?: MarkerLayerPointTypeEnum; // Marker shape type
234
+ pointSize?: number; // Marker size (pixels)
235
+ pointText?: string; // Text content for text marker
236
+ pointAnimationType?: MarkerLayerAnimationTypeEnum; // Animation effect type
237
+ pointHtml?: string; // HTML content for HTML marker
238
+ pointHtmlWidth?: number; // HTML marker width (pixels)
239
+ pointHtmlHeight?: number; // HTML marker height (pixels)
240
+ onClick?: (data: MarkerLayerData, event: any) => void; // Click callback
241
+ onContextMenu?: (data: MarkerLayerData, event: any) => void; // Right-click callback
242
+ onHover?: (data: MarkerLayerData, event: any) => void; // Hover callback
243
+ }
244
+ ```
245
+
246
+ #### Marker shape type enum
247
+
248
+ ```typescipt
249
+ export enum MarkerLayerPointTypeEnum {
250
+ SQUARE = "square", // Square
251
+ CIRCLE = "circle", // Circle
252
+ TRIANGLE = "triangle", // Triangle
253
+ PENTAGRAM = "pentagram", // Pentagram
254
+ TEXT = "text", // Text marker
255
+ DIAMOND = "diamond", // Diamond
256
+ CROSS = "cross", // Cross
257
+ X_SHAPE = "x_shape", // X Shape
258
+ HEXAGON = "hexagon", // Hexagon
259
+ FLAG = "flag", // Flag
260
+ HOUSE = "house", // House
261
+ ARROW = "arrow", // Arrow
262
+ TENT = "tent", // Tent - Camp, temporary post
263
+ BUNKER = "bunker", // Bunker - Fortification, fire point
264
+ LANDMINE = "landmine", // Landmine - Minefield, explosives
265
+ TANK = "tank", // Tank - Armored unit, heavy equipment
266
+ PLANE = "plane", // Plane - Airport, airstrip, aviation facility
267
+ SHIP = "ship", // Ship - Port, landing point, naval facility
268
+ RADAR = "radar", // Radar - Monitoring station, early warning point
269
+ MISSILE = "missile", // Missile - Missile site, launch point
270
+ FIRE_HYDRANT = "fire_hydrant", // Fire Hydrant - Fire facility
271
+ FIRST_AID = "first_aid", // First Aid - Medical supply point
272
+ WATER_TOWER = "water_tower", // Water Tower - Water source, reservoir
273
+ GENERATOR = "generator", // Generator - Power facility
274
+ MEGAPHONE = "megaphone", // Megaphone - Broadcast point, alert point
275
+ STREET_LAMP = "street_lamp", // Street Lamp - Lighting facility
276
+ PARKING = "parking", // Parking - Parking lot
277
+ GAS_STATION = "gas_station", // Gas Station - Fuel/charging station
278
+ TUNNEL = "tunnel", // Tunnel - Tunnel entrance
279
+ BRIDGE = "bridge", // Bridge - Elevated road
280
+ TRAFFIC_LIGHT = "traffic_light", // Traffic Light - Traffic signal point
281
+ CAMERA = "camera", // Camera - Monitoring point
282
+ TOILET = "toilet", // Toilet - Public restroom
283
+ TRASH_CAN = "trash_can", // Trash Can - Waste collection point
284
+ BUS_STOP = "bus_stop", // Bus Stop - Bus station
285
+ SUBWAY = "subway", // Subway - Subway entrance
286
+ SCHOOL = "school", // School - Educational institution
287
+ HOSPITAL = "hospital", // Hospital - Medical facility
288
+ TREE = "tree", // Tree - Forest, green area
289
+ WATER_SOURCE = "water_source", // Water Source - River, lake, well
290
+ MOUNTAIN = "mountain", // Mountain - Peak, high point
291
+ MINE = "mine", // Mine - Mining point, quarry
292
+ HEART = "heart", // Heart - Important attention point
293
+ STAR = "star", // Star - Commendation point, excellent spot
294
+ CLOUD = "cloud", // Cloud - Cloud service node
295
+ GEAR = "gear", // Gear - Industrial facility
296
+ LIGHTNING = "lightning", // Lightning - Power facility
297
+ PIN = "pin", // Pin - General marker point
298
+ COMPASS = "compass", // Compass - Direction reference point
299
+ ANCHOR = "anchor", // Anchor - Harbor, dock
300
+ }
301
+ ```
302
+
303
+ #### Marker animation type enum
304
+
305
+ ```typescipt
306
+ export enum MarkerLayerAnimationTypeEnum {
307
+ PULSE = "pulse", // Pulse animation - Marker size changes periodically
308
+ FLASHING = "flashing", // Flashing animation - Marker color alternates
309
+ BREATHING = "breathing", // Breathing animation - Marker opacity changes slowly
310
+ LIGHT = "light" // Light animation - Glow effect around marker
311
+ }
312
+ ```
313
+
314
+ #### MarkerLayer Demo
315
+
316
+ <img src="https://raw.githubusercontent.com/0xhappyboy/earthview/main/assets/marker_layer_demo.gif" width="100%">
317
+
318
+ ## Data Layer Management Panel
319
+
320
+ <img src="https://raw.githubusercontent.com/0xhappyboy/earthview/main/assets/data_layer_manager_demo.gif" width="100%">