ofs-object 0.1.1 → 0.1.4

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/docs/API.md CHANGED
@@ -17,8 +17,12 @@ const layer = ofs.dataSource.addLayer({
17
17
  name: 'คลองส่งน้ำ',
18
18
  type: 'line',
19
19
  zIndex: 2,
20
+ color: '#0ea5e9', // ไม่ใส่ก็ได้ — จะได้สีที่ต่างจากเลเยอร์ที่อยู่บนแผนที่อย่างชัดเจน (สุ่ม)
20
21
  });
21
22
 
23
+ // สีที่อ่านไม่ออก เช่น 'greenish' → throw OFSError ก่อนเพิ่มเลเยอร์
24
+ // อยากได้สีเดิมทุกครั้ง (เทสต์ / screenshot): new OFSThematicEngine({ random: seededFn })
25
+
22
26
  // เพิ่ม Feature พร้อม Undo Record อัตโนมัติ
23
27
  ofs.dataSource.addFeature('canals', lineGeoJsonFeature);
24
28
 
@@ -399,16 +403,25 @@ macro play ตรวจแปลง --times 2
399
403
 
400
404
  รองรับทั้ง MapLibre GL และ Mapbox GL ด้วย Interface เดียวกัน:
401
405
 
406
+ **ไลบรารีไม่ `import` map engine ตัวไหนเลย** ถ้า import ไว้ มันจะเป็น dependency บังคับของทุกคน
407
+ คนที่ใช้ Mapbox และไม่ได้ลง `maplibre-gl` จะ build ไม่ผ่านด้วย `Can't resolve 'maplibre-gl'`
408
+ ตั้งแต่ยังไม่ได้รันโค้ด → **ต้องส่ง library เข้ามาตอน `init()`**
409
+
402
410
  ```typescript
403
411
  import { MapLibreAdapter, MapboxAdapter } from 'ofs-object';
412
+ import * as maplibregl from 'maplibre-gl'; // v6 ไม่มี default export
413
+ import mapboxgl from 'mapbox-gl';
404
414
 
405
415
  // สำหรับ MapLibre GL JS
406
416
  const mapAdapter = new MapLibreAdapter();
417
+ await mapAdapter.init('map-div', { maplibregl, center: [100.5, 13.7], zoom: 14 });
407
418
 
408
419
  // หรือสำหรับ Mapbox GL JS
409
420
  const mapAdapter = new MapboxAdapter();
410
-
421
+ // เลเยอร์ที่ ≤ 5,000 feature ส่งเฉพาะส่วนที่เปลี่ยน (Mapbox ≥ 3.4) เลเยอร์ใหญ่กว่าส่งทั้งชุด
422
+ // ปรับได้: mapAdapter.dynamicSourceMaxFeatures = 2000 (0 = ส่งทั้งชุดเสมอ)
411
423
  await mapAdapter.init('map-div', {
424
+ mapboxgl,
412
425
  accessToken: 'YOUR_MAPBOX_TOKEN',
413
426
  style: 'mapbox://styles/mapbox/satellite-streets-v12',
414
427
  center: [100.5, 13.7],
@@ -429,6 +442,7 @@ const map = new maplibregl.Map({ container: el, style, center: [100.5, 13.7], zo
429
442
 
430
443
  const ofs = new OFSObject({ map }); // Mapbox: เพิ่ม mapAdapter: new MapboxAdapter()
431
444
  await ofs.init(); // ไม่ต้องส่ง container — รอ style พร้อมแล้วผูกให้เอง
445
+ // และไม่ต้องส่ง map engine เพราะไม่ได้สร้างแผนที่เอง
432
446
 
433
447
  // หรือเรียกที่ adapter ตรง ๆ
434
448
  await ofs.mapAdapter.attach(map);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ofs-object",
3
- "version": "0.1.1",
3
+ "version": "0.1.4",
4
4
  "description": "Framework-agnostic TypeScript Library for GIS Map Tools (Data Adapter, Draw Tools, Legend & Thematic Symbology, Map Adapters, Web CLI & AI Bridge)",
5
5
  "license": "MIT",
6
6
  "author": "On-Farm Solution Co.,Ltd.",