@earthview/core 0.1.1 → 0.2.0

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