@biza-gov/map 0.0.0-stage → 1.0.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.
package/README.md CHANGED
@@ -1,3 +1,71 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # @biza-gov/map
2
+
3
+ ชิ้นส่วนแผนที่สำหรับ e-service ที่วาดแผนที่เอง (วิธี B ของแผนที่กลาง GovCenter) ด้วย [MapLibre GL](https://maplibre.org/) ได้แผนที่แบบ dashboard ของ landslide ทันที:
4
+
5
+ - แผนที่ฐานฟรี 3 แบบ: ดาวเทียม · ภูมิประเทศ · ถนน
6
+ - **3D ภูมิประเทศ** + แรเงาภูเขา เอียงและหมุนได้แบบ Google Maps (ลาก = เลื่อน, scroll = ซูม, คลิกขวาลาก/สองนิ้ว = เอียงและหมุน)
7
+ - วาด layer ของ GovCenter (`GET /e-services/gis/map-data`) ด้วยสีมาตรฐานเดียวกับแผนที่กลาง พร้อมวงรัศมีของแจ้งเตือนแบบพื้นที่
8
+
9
+ ใช้ฝั่งหน้าเว็บ (ไม่มี API key) ข้อมูลมาจาก backend ของ e-service ที่เรียก GovCenter ให้
10
+
11
+ ## ติดตั้ง
12
+
13
+ ```bash
14
+ npm install @biza-gov/map maplibre-gl
15
+ ```
16
+
17
+ ## ใช้งาน
18
+
19
+ ```ts
20
+ import maplibregl from 'maplibre-gl';
21
+ import 'maplibre-gl/dist/maplibre-gl.css';
22
+ import { addGovCenterLayers, createGovMap, set3D, setBasemap } from '@biza-gov/map';
23
+
24
+ const map = createGovMap(maplibregl, {
25
+ container: 'map',
26
+ center: [98.39, 7.88], // [lng, lat]
27
+ threeD: true,
28
+ });
29
+
30
+ map.on('load', async () => {
31
+ // backend ของ e-service เรียก GET {GOVCENTER_API_URL}/e-services/gis/map-data ให้
32
+ const data = await fetch('/api/map-data?layers=stations,municipality,notifications').then((r) => r.json());
33
+ addGovCenterLayers(map, data, {
34
+ onClick: (layer, properties, lngLat) => new maplibregl.Popup().setLngLat(lngLat).setText(String(properties.name ?? layer)).addTo(map),
35
+ });
36
+ if (data.bounds) map.fitBounds(data.bounds, { padding: 48, maxZoom: 15 });
37
+ });
38
+
39
+ // ปุ่มของหน้าเว็บ
40
+ set3D(map, false); // กลับเป็น 2D
41
+ setBasemap(map, 'streets'); // 'satellite' | 'topo' | 'streets'
42
+ ```
43
+
44
+ ## API
45
+
46
+ | ชื่อ | ใช้ทำอะไร |
47
+ | --- | --- |
48
+ | `createGovMap(maplibregl, { container, center?, zoom?, threeD?, basemap?, mapOptions? })` | สร้างแผนที่พร้อมปุ่มซูม/เข็มทิศ/เอียง และมาตราส่วน |
49
+ | `set3D(map, on, { exaggeration? })` | เปิด/ปิด 3D (ค่าเริ่มต้นยกพื้น 1.5 เท่า เอียง 60°) |
50
+ | `setBasemap(map, id)` · `FREE_BASEMAPS` | สลับแผนที่ฐาน · รายการสำหรับทำปุ่มเลือก |
51
+ | `freeStyle(initial?)` | style ของแผนที่ฐานฟรี + terrain (ใช้กับ `new maplibregl.Map` เองได้) |
52
+ | `addGovCenterLayers(map, data, { onClick? })` | วาด/อัปเดต layer จาก map-data คืน id ของ layer |
53
+ | `setGovCenterLayerVisible(map, layer, visible)` | เปิด/ปิด layer |
54
+ | `LAYER_STYLE` · `STATION_STYLE` | ชื่อไทยและสีของแต่ละ layer / ชนิดสถานี (ทำ legend) |
55
+ | `circlePolygon(lng, lat, km)` | วงกลมรัศมีเป็น polygon |
56
+ | `MapDataResponse` | type ของผลลัพธ์ map-data |
57
+
58
+ ## ข้อควรรู้
59
+
60
+ - แผนที่ฐานฟรี (Esri, OpenTopoMap, OpenStreetMap, AWS Terrain) เหมาะกับพัฒนาและใช้งานปริมาณน้อย ระบบจริงที่ผู้ใช้มากควรใช้ tile ของตัวเองหรือผู้ให้บริการแบบเสียเงิน (ส่ง `mapOptions.style` เอง)
61
+ - ตึก 3D ต้องใช้ vector tile ที่มีความสูงตึก (เช่น Mapbox, MapTiler) แผนที่ฐานฟรีมีแค่ภูมิประเทศ
62
+ - อย่าใช้ข้อมูล `home`/`residences` ร่วมกันระหว่างผู้ใช้ (ข้อมูลส่วนบุคคล)
63
+ - ไม่อยากวาดเอง: ใช้แผนที่ฝังของ GovCenter ส่ง `"view": "3d"` ตอนสร้าง map session
64
+
65
+ ## พัฒนา
66
+
67
+ ```bash
68
+ npm install
69
+ npm run build
70
+ npm test
71
+ ```
@@ -0,0 +1,119 @@
1
+ import { HillshadeLayerSpecification, StyleSpecification, Map, ExpressionSpecification, LngLatLike, MapOptions } from 'maplibre-gl';
2
+ import { FeatureCollection, Point, Polygon } from 'geojson';
3
+
4
+ /**
5
+ * Free basemaps (satellite, topographic, streets) and elevation for 3D, as on the landslide
6
+ * dashboard. Free tiles suit development and light use; a production e-service with heavy
7
+ * traffic should serve its own or a paid provider's tiles.
8
+ */
9
+ type BasemapId = 'satellite' | 'topo' | 'streets';
10
+ /** In the order a basemap picker shows them. */
11
+ declare const FREE_BASEMAPS: {
12
+ id: BasemapId;
13
+ label: string;
14
+ }[];
15
+ declare const DEM_SOURCE: {
16
+ type: "raster-dem";
17
+ tiles: string[];
18
+ tileSize: number;
19
+ maxzoom: number;
20
+ encoding: "terrarium";
21
+ };
22
+ declare const HILLSHADE_LAYER: HillshadeLayerSpecification;
23
+ /** The style for `new maplibregl.Map({ style })`: every free basemap, satellite shown first. */
24
+ declare function freeStyle(initial?: BasemapId): StyleSpecification;
25
+ /** Shows one basemap of `freeStyle` and hides the others. */
26
+ declare function setBasemap(map: Map, id: BasemapId): void;
27
+
28
+ declare const TERRAIN_EXAGGERATION = 1.5;
29
+ declare const TILTED_PITCH = 60;
30
+ /**
31
+ * Terrain in relief and a tilted camera, or back to flat. Needs a raster-dem source named
32
+ * `terrain` (as in `freeStyle`). Tilting only from zoom 9 keeps a country-wide view readable.
33
+ */
34
+ declare function set3D(map: Map, on: boolean, { exaggeration, source }?: {
35
+ exaggeration?: number | undefined;
36
+ source?: string | undefined;
37
+ }): void;
38
+
39
+ /**
40
+ * The layers of GovCenter's central map (Core 5), as `GET /e-services/gis/map-data` returns them,
41
+ * drawn with the colors every GovCenter map uses.
42
+ */
43
+ type GovCenterLayer = 'home' | 'residences' | 'municipality' | 'stations' | 'notifications' | 'evaluations';
44
+ type StationType = 'EVACUATION_SITE' | 'OFFICE' | 'STATION' | 'SENSOR' | 'UAV' | 'CCTV' | 'SIREN' | 'OTHER';
45
+ /** The body of `GET /e-services/gis/map-data`. */
46
+ interface MapDataResponse {
47
+ basemap?: {
48
+ provider: string;
49
+ style: string;
50
+ accessToken: string | null;
51
+ attribution: string;
52
+ };
53
+ /** [minLng, minLat, maxLng, maxLat] of every point, null when there is none. */
54
+ bounds: [number, number, number, number] | null;
55
+ generatedAt?: string;
56
+ layers: Partial<Record<GovCenterLayer, FeatureCollection<Point>>>;
57
+ }
58
+ declare const LAYER_STYLE: Record<GovCenterLayer, {
59
+ label: string;
60
+ color: string;
61
+ }>;
62
+ declare const STATION_STYLE: Record<StationType, {
63
+ label: string;
64
+ color: string;
65
+ }>;
66
+ declare const EMERGENCY_COLOR = "#dc2626";
67
+ /** A circle of radiusKm around [lng, lat], as a polygon. */
68
+ declare function circlePolygon(lng: number, lat: number, radiusKm: number): Polygon;
69
+ /** The fill of every area notification: a circle of its radius around its center. */
70
+ declare function notificationAreas(notifications?: FeatureCollection<Point>): FeatureCollection<Polygon>;
71
+ /** The circle color of a layer: stations by type, notifications red when they are emergencies. */
72
+ declare function layerColor(layer: GovCenterLayer): string | ExpressionSpecification;
73
+ declare const govCenterLayerId: (layer: GovCenterLayer) => string;
74
+ interface GovCenterLayerOptions {
75
+ /** Called when a point is clicked, with its layer and properties. */
76
+ onClick?: (layer: GovCenterLayer, properties: Record<string, unknown>, lngLat: {
77
+ lng: number;
78
+ lat: number;
79
+ }) => void;
80
+ }
81
+ /**
82
+ * Draws every layer of a map-data response, or updates its data when already drawn. Call after
83
+ * the map's `load` event. Returns the ids of the point layers it drew.
84
+ */
85
+ declare function addGovCenterLayers(map: Map, data: MapDataResponse, options?: GovCenterLayerOptions): string[];
86
+ /** Shows or hides one GovCenter layer (and the notification areas with the notifications). */
87
+ declare function setGovCenterLayerVisible(map: Map, layer: GovCenterLayer, visible: boolean): void;
88
+
89
+ /** Thailand, for a map that opens without a center. */
90
+ declare const THAILAND_CENTER: [number, number];
91
+ interface GovMapOptions {
92
+ container: HTMLElement | string;
93
+ center?: LngLatLike;
94
+ zoom?: number;
95
+ /** Open with the terrain in relief, tilted. */
96
+ threeD?: boolean;
97
+ basemap?: BasemapId;
98
+ /** Anything else MapLibre takes; wins over the defaults above. */
99
+ mapOptions?: Partial<MapOptions>;
100
+ }
101
+ /** The MapLibre module, passed in so this package never bundles it: `import maplibregl from 'maplibre-gl'`. */
102
+ interface MapLibreModule {
103
+ Map: new (options: MapOptions) => Map;
104
+ NavigationControl: new (options?: {
105
+ visualizePitch?: boolean;
106
+ showCompass?: boolean;
107
+ }) => unknown;
108
+ ScaleControl: new (options?: {
109
+ unit?: 'metric';
110
+ }) => unknown;
111
+ }
112
+ /**
113
+ * A map that moves like Google Maps: drag to pan, scroll to zoom, right-drag or two fingers to
114
+ * tilt and rotate, with zoom/compass buttons and a scale bar. The free basemaps and terrain are
115
+ * in its style, so `set3D` and `setBasemap` work right away.
116
+ */
117
+ declare function createGovMap(maplibregl: MapLibreModule, options: GovMapOptions): Map;
118
+
119
+ export { type BasemapId, DEM_SOURCE, EMERGENCY_COLOR, FREE_BASEMAPS, type GovCenterLayer, type GovCenterLayerOptions, type GovMapOptions, HILLSHADE_LAYER, LAYER_STYLE, type MapDataResponse, type MapLibreModule, STATION_STYLE, type StationType, TERRAIN_EXAGGERATION, THAILAND_CENTER, TILTED_PITCH, addGovCenterLayers, circlePolygon, createGovMap, freeStyle, govCenterLayerId, layerColor, notificationAreas, set3D, setBasemap, setGovCenterLayerVisible };
@@ -0,0 +1,119 @@
1
+ import { HillshadeLayerSpecification, StyleSpecification, Map, ExpressionSpecification, LngLatLike, MapOptions } from 'maplibre-gl';
2
+ import { FeatureCollection, Point, Polygon } from 'geojson';
3
+
4
+ /**
5
+ * Free basemaps (satellite, topographic, streets) and elevation for 3D, as on the landslide
6
+ * dashboard. Free tiles suit development and light use; a production e-service with heavy
7
+ * traffic should serve its own or a paid provider's tiles.
8
+ */
9
+ type BasemapId = 'satellite' | 'topo' | 'streets';
10
+ /** In the order a basemap picker shows them. */
11
+ declare const FREE_BASEMAPS: {
12
+ id: BasemapId;
13
+ label: string;
14
+ }[];
15
+ declare const DEM_SOURCE: {
16
+ type: "raster-dem";
17
+ tiles: string[];
18
+ tileSize: number;
19
+ maxzoom: number;
20
+ encoding: "terrarium";
21
+ };
22
+ declare const HILLSHADE_LAYER: HillshadeLayerSpecification;
23
+ /** The style for `new maplibregl.Map({ style })`: every free basemap, satellite shown first. */
24
+ declare function freeStyle(initial?: BasemapId): StyleSpecification;
25
+ /** Shows one basemap of `freeStyle` and hides the others. */
26
+ declare function setBasemap(map: Map, id: BasemapId): void;
27
+
28
+ declare const TERRAIN_EXAGGERATION = 1.5;
29
+ declare const TILTED_PITCH = 60;
30
+ /**
31
+ * Terrain in relief and a tilted camera, or back to flat. Needs a raster-dem source named
32
+ * `terrain` (as in `freeStyle`). Tilting only from zoom 9 keeps a country-wide view readable.
33
+ */
34
+ declare function set3D(map: Map, on: boolean, { exaggeration, source }?: {
35
+ exaggeration?: number | undefined;
36
+ source?: string | undefined;
37
+ }): void;
38
+
39
+ /**
40
+ * The layers of GovCenter's central map (Core 5), as `GET /e-services/gis/map-data` returns them,
41
+ * drawn with the colors every GovCenter map uses.
42
+ */
43
+ type GovCenterLayer = 'home' | 'residences' | 'municipality' | 'stations' | 'notifications' | 'evaluations';
44
+ type StationType = 'EVACUATION_SITE' | 'OFFICE' | 'STATION' | 'SENSOR' | 'UAV' | 'CCTV' | 'SIREN' | 'OTHER';
45
+ /** The body of `GET /e-services/gis/map-data`. */
46
+ interface MapDataResponse {
47
+ basemap?: {
48
+ provider: string;
49
+ style: string;
50
+ accessToken: string | null;
51
+ attribution: string;
52
+ };
53
+ /** [minLng, minLat, maxLng, maxLat] of every point, null when there is none. */
54
+ bounds: [number, number, number, number] | null;
55
+ generatedAt?: string;
56
+ layers: Partial<Record<GovCenterLayer, FeatureCollection<Point>>>;
57
+ }
58
+ declare const LAYER_STYLE: Record<GovCenterLayer, {
59
+ label: string;
60
+ color: string;
61
+ }>;
62
+ declare const STATION_STYLE: Record<StationType, {
63
+ label: string;
64
+ color: string;
65
+ }>;
66
+ declare const EMERGENCY_COLOR = "#dc2626";
67
+ /** A circle of radiusKm around [lng, lat], as a polygon. */
68
+ declare function circlePolygon(lng: number, lat: number, radiusKm: number): Polygon;
69
+ /** The fill of every area notification: a circle of its radius around its center. */
70
+ declare function notificationAreas(notifications?: FeatureCollection<Point>): FeatureCollection<Polygon>;
71
+ /** The circle color of a layer: stations by type, notifications red when they are emergencies. */
72
+ declare function layerColor(layer: GovCenterLayer): string | ExpressionSpecification;
73
+ declare const govCenterLayerId: (layer: GovCenterLayer) => string;
74
+ interface GovCenterLayerOptions {
75
+ /** Called when a point is clicked, with its layer and properties. */
76
+ onClick?: (layer: GovCenterLayer, properties: Record<string, unknown>, lngLat: {
77
+ lng: number;
78
+ lat: number;
79
+ }) => void;
80
+ }
81
+ /**
82
+ * Draws every layer of a map-data response, or updates its data when already drawn. Call after
83
+ * the map's `load` event. Returns the ids of the point layers it drew.
84
+ */
85
+ declare function addGovCenterLayers(map: Map, data: MapDataResponse, options?: GovCenterLayerOptions): string[];
86
+ /** Shows or hides one GovCenter layer (and the notification areas with the notifications). */
87
+ declare function setGovCenterLayerVisible(map: Map, layer: GovCenterLayer, visible: boolean): void;
88
+
89
+ /** Thailand, for a map that opens without a center. */
90
+ declare const THAILAND_CENTER: [number, number];
91
+ interface GovMapOptions {
92
+ container: HTMLElement | string;
93
+ center?: LngLatLike;
94
+ zoom?: number;
95
+ /** Open with the terrain in relief, tilted. */
96
+ threeD?: boolean;
97
+ basemap?: BasemapId;
98
+ /** Anything else MapLibre takes; wins over the defaults above. */
99
+ mapOptions?: Partial<MapOptions>;
100
+ }
101
+ /** The MapLibre module, passed in so this package never bundles it: `import maplibregl from 'maplibre-gl'`. */
102
+ interface MapLibreModule {
103
+ Map: new (options: MapOptions) => Map;
104
+ NavigationControl: new (options?: {
105
+ visualizePitch?: boolean;
106
+ showCompass?: boolean;
107
+ }) => unknown;
108
+ ScaleControl: new (options?: {
109
+ unit?: 'metric';
110
+ }) => unknown;
111
+ }
112
+ /**
113
+ * A map that moves like Google Maps: drag to pan, scroll to zoom, right-drag or two fingers to
114
+ * tilt and rotate, with zoom/compass buttons and a scale bar. The free basemaps and terrain are
115
+ * in its style, so `set3D` and `setBasemap` work right away.
116
+ */
117
+ declare function createGovMap(maplibregl: MapLibreModule, options: GovMapOptions): Map;
118
+
119
+ export { type BasemapId, DEM_SOURCE, EMERGENCY_COLOR, FREE_BASEMAPS, type GovCenterLayer, type GovCenterLayerOptions, type GovMapOptions, HILLSHADE_LAYER, LAYER_STYLE, type MapDataResponse, type MapLibreModule, STATION_STYLE, type StationType, TERRAIN_EXAGGERATION, THAILAND_CENTER, TILTED_PITCH, addGovCenterLayers, circlePolygon, createGovMap, freeStyle, govCenterLayerId, layerColor, notificationAreas, set3D, setBasemap, setGovCenterLayerVisible };
package/dist/index.js ADDED
@@ -0,0 +1,275 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ DEM_SOURCE: () => DEM_SOURCE,
24
+ EMERGENCY_COLOR: () => EMERGENCY_COLOR,
25
+ FREE_BASEMAPS: () => FREE_BASEMAPS,
26
+ HILLSHADE_LAYER: () => HILLSHADE_LAYER,
27
+ LAYER_STYLE: () => LAYER_STYLE,
28
+ STATION_STYLE: () => STATION_STYLE,
29
+ TERRAIN_EXAGGERATION: () => TERRAIN_EXAGGERATION,
30
+ THAILAND_CENTER: () => THAILAND_CENTER,
31
+ TILTED_PITCH: () => TILTED_PITCH,
32
+ addGovCenterLayers: () => addGovCenterLayers,
33
+ circlePolygon: () => circlePolygon,
34
+ createGovMap: () => createGovMap,
35
+ freeStyle: () => freeStyle,
36
+ govCenterLayerId: () => govCenterLayerId,
37
+ layerColor: () => layerColor,
38
+ notificationAreas: () => notificationAreas,
39
+ set3D: () => set3D,
40
+ setBasemap: () => setBasemap,
41
+ setGovCenterLayerVisible: () => setGovCenterLayerVisible
42
+ });
43
+ module.exports = __toCommonJS(index_exports);
44
+
45
+ // src/basemaps.ts
46
+ var FREE_BASEMAPS = [
47
+ { id: "satellite", label: "\u0E14\u0E32\u0E27\u0E40\u0E17\u0E35\u0E22\u0E21" },
48
+ { id: "topo", label: "\u0E20\u0E39\u0E21\u0E34\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28" },
49
+ { id: "streets", label: "\u0E16\u0E19\u0E19" }
50
+ ];
51
+ var DEM_TILES = ["https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"];
52
+ var DEM_SOURCE = {
53
+ type: "raster-dem",
54
+ tiles: DEM_TILES,
55
+ tileSize: 256,
56
+ maxzoom: 15,
57
+ encoding: "terrarium"
58
+ };
59
+ var HILLSHADE_LAYER = {
60
+ id: "hillshade",
61
+ type: "hillshade",
62
+ source: "hillshadeDem",
63
+ paint: { "hillshade-exaggeration": 0.4, "hillshade-shadow-color": "#0b1220" }
64
+ };
65
+ function freeStyle(initial = "satellite") {
66
+ const visibility = (id) => id === initial ? "visible" : "none";
67
+ return {
68
+ version: 8,
69
+ sources: {
70
+ satellite: {
71
+ type: "raster",
72
+ tiles: [
73
+ "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
74
+ ],
75
+ tileSize: 256,
76
+ maxzoom: 18,
77
+ attribution: "Imagery \xA9 Esri, Maxar, Earthstar Geographics"
78
+ },
79
+ topo: {
80
+ type: "raster",
81
+ tiles: ["a", "b", "c"].map((s) => `https://${s}.tile.opentopomap.org/{z}/{x}/{y}.png`),
82
+ tileSize: 256,
83
+ // OpenTopoMap is a volunteer server that throttles bursts; above z15 tiles are overzoomed.
84
+ maxzoom: 15,
85
+ attribution: "\xA9 OpenTopoMap (CC-BY-SA) \xA9 OpenStreetMap contributors"
86
+ },
87
+ streets: {
88
+ type: "raster",
89
+ tiles: ["https://tile.openstreetmap.org/{z}/{x}/{y}.png"],
90
+ tileSize: 256,
91
+ maxzoom: 19,
92
+ attribution: "\xA9 OpenStreetMap contributors"
93
+ },
94
+ // MapLibre recommends separate DEM sources for the 3D mesh and the hillshade.
95
+ terrain: { ...DEM_SOURCE, attribution: "Terrain: AWS Terrain Tiles (SRTM et al.)" },
96
+ hillshadeDem: DEM_SOURCE
97
+ },
98
+ layers: [
99
+ { id: "base-satellite", type: "raster", source: "satellite", layout: { visibility: visibility("satellite") } },
100
+ { id: "base-topo", type: "raster", source: "topo", layout: { visibility: visibility("topo") } },
101
+ { id: "base-streets", type: "raster", source: "streets", layout: { visibility: visibility("streets") } },
102
+ HILLSHADE_LAYER
103
+ ]
104
+ };
105
+ }
106
+ function setBasemap(map, id) {
107
+ for (const b of FREE_BASEMAPS) {
108
+ map.setLayoutProperty(`base-${b.id}`, "visibility", b.id === id ? "visible" : "none");
109
+ }
110
+ }
111
+
112
+ // src/three-d.ts
113
+ var TERRAIN_EXAGGERATION = 1.5;
114
+ var TILTED_PITCH = 60;
115
+ function set3D(map, on, { exaggeration = TERRAIN_EXAGGERATION, source = "terrain" } = {}) {
116
+ map.setTerrain(on ? { source, exaggeration } : null);
117
+ map.easeTo({
118
+ pitch: on ? Math.max(map.getPitch(), map.getZoom() > 9 ? TILTED_PITCH : 0) : 0,
119
+ bearing: on ? map.getBearing() : 0,
120
+ duration: 600
121
+ });
122
+ }
123
+
124
+ // src/govcenter.ts
125
+ var LAYER_STYLE = {
126
+ home: { label: "\u0E1A\u0E49\u0E32\u0E19\u0E02\u0E2D\u0E07\u0E09\u0E31\u0E19", color: "#e11d48" },
127
+ residences: { label: "\u0E1A\u0E49\u0E32\u0E19\u0E43\u0E19\u0E1E\u0E37\u0E49\u0E19\u0E17\u0E35\u0E48", color: "#0d9488" },
128
+ municipality: { label: "\u0E2A\u0E33\u0E19\u0E31\u0E01\u0E07\u0E32\u0E19\u0E17\u0E49\u0E2D\u0E07\u0E16\u0E34\u0E48\u0E19", color: "#4f46e5" },
129
+ stations: { label: "\u0E2A\u0E16\u0E32\u0E19\u0E35\u0E41\u0E25\u0E30\u0E2D\u0E38\u0E1B\u0E01\u0E23\u0E13\u0E4C", color: "#64748b" },
130
+ notifications: { label: "\u0E01\u0E32\u0E23\u0E41\u0E08\u0E49\u0E07\u0E40\u0E15\u0E37\u0E2D\u0E19", color: "#d97706" },
131
+ evaluations: { label: "\u0E04\u0E27\u0E32\u0E21\u0E1E\u0E36\u0E07\u0E1E\u0E2D\u0E43\u0E08", color: "#ca8a04" }
132
+ };
133
+ var STATION_STYLE = {
134
+ EVACUATION_SITE: { label: "\u0E2A\u0E16\u0E32\u0E19\u0E17\u0E35\u0E48\u0E2D\u0E1E\u0E22\u0E1E", color: "#16a34a" },
135
+ OFFICE: { label: "\u0E2A\u0E33\u0E19\u0E31\u0E01\u0E07\u0E32\u0E19", color: "#2563eb" },
136
+ STATION: { label: "\u0E2A\u0E16\u0E32\u0E19\u0E35\u0E15\u0E23\u0E27\u0E08\u0E27\u0E31\u0E14", color: "#0891b2" },
137
+ SENSOR: { label: "\u0E40\u0E0B\u0E19\u0E40\u0E0B\u0E2D\u0E23\u0E4C", color: "#7c3aed" },
138
+ UAV: { label: "\u0E2D\u0E38\u0E1B\u0E01\u0E23\u0E13\u0E4C\u0E40\u0E04\u0E25\u0E37\u0E48\u0E2D\u0E19\u0E17\u0E35\u0E48", color: "#ea580c" },
139
+ CCTV: { label: "CCTV", color: "#475569" },
140
+ SIREN: { label: "\u0E2B\u0E2D\u0E40\u0E15\u0E37\u0E2D\u0E19\u0E20\u0E31\u0E22", color: "#dc2626" },
141
+ OTHER: { label: "\u0E2D\u0E37\u0E48\u0E19 \u0E46", color: "#64748b" }
142
+ };
143
+ var EMERGENCY_COLOR = "#dc2626";
144
+ function circlePolygon(lng, lat, radiusKm) {
145
+ const ring = [];
146
+ const dLat = radiusKm / 110.574;
147
+ const dLng = radiusKm / (111.32 * Math.cos(lat * Math.PI / 180));
148
+ for (let i = 0; i <= 64; i++) {
149
+ const a = i / 64 * 2 * Math.PI;
150
+ ring.push([lng + dLng * Math.cos(a), lat + dLat * Math.sin(a)]);
151
+ }
152
+ return { type: "Polygon", coordinates: [ring] };
153
+ }
154
+ function notificationAreas(notifications) {
155
+ return {
156
+ type: "FeatureCollection",
157
+ features: (notifications?.features ?? []).flatMap((f) => {
158
+ const radiusKm = Number(f.properties?.radiusKm);
159
+ if (!(radiusKm > 0)) return [];
160
+ const [lng, lat] = f.geometry.coordinates;
161
+ return [{ type: "Feature", geometry: circlePolygon(lng, lat, radiusKm), properties: f.properties }];
162
+ })
163
+ };
164
+ }
165
+ function layerColor(layer) {
166
+ if (layer === "stations") {
167
+ return [
168
+ "match",
169
+ ["get", "type"],
170
+ ...Object.entries(STATION_STYLE).flatMap(([type, s]) => [type, s.color]),
171
+ STATION_STYLE.OTHER.color
172
+ ];
173
+ }
174
+ if (layer === "notifications") {
175
+ return ["case", ["==", ["get", "emergency"], true], EMERGENCY_COLOR, LAYER_STYLE.notifications.color];
176
+ }
177
+ return LAYER_STYLE[layer].color;
178
+ }
179
+ var govCenterLayerId = (layer) => `gc-${layer}`;
180
+ var AREAS_ID = "gc-notification-areas";
181
+ function addGovCenterLayers(map, data, options = {}) {
182
+ const ids = [];
183
+ const areas = notificationAreas(data.layers.notifications);
184
+ if (areas.features.length) {
185
+ const existing = map.getSource(AREAS_ID);
186
+ if (existing?.setData) existing.setData(areas);
187
+ else {
188
+ map.addSource(AREAS_ID, { type: "geojson", data: areas });
189
+ map.addLayer({
190
+ id: AREAS_ID,
191
+ type: "fill",
192
+ source: AREAS_ID,
193
+ paint: { "fill-color": layerColor("notifications"), "fill-opacity": 0.15 }
194
+ });
195
+ }
196
+ }
197
+ for (const [name, collection] of Object.entries(data.layers)) {
198
+ if (!collection || !(name in LAYER_STYLE)) continue;
199
+ const id = govCenterLayerId(name);
200
+ ids.push(id);
201
+ const existing = map.getSource(id);
202
+ if (existing?.setData) {
203
+ existing.setData(collection);
204
+ continue;
205
+ }
206
+ map.addSource(id, { type: "geojson", data: collection });
207
+ map.addLayer({
208
+ id,
209
+ type: "circle",
210
+ source: id,
211
+ paint: {
212
+ "circle-radius": name === "residences" ? 4 : 7,
213
+ "circle-color": layerColor(name),
214
+ "circle-stroke-color": "#ffffff",
215
+ "circle-stroke-width": 2
216
+ }
217
+ });
218
+ if (options.onClick) {
219
+ map.on("click", id, (e) => {
220
+ const f = e.features?.[0];
221
+ if (f) options.onClick?.(name, f.properties ?? {}, e.lngLat);
222
+ });
223
+ map.on("mouseenter", id, () => map.getCanvas().style.cursor = "pointer");
224
+ map.on("mouseleave", id, () => map.getCanvas().style.cursor = "");
225
+ }
226
+ }
227
+ return ids;
228
+ }
229
+ function setGovCenterLayerVisible(map, layer, visible) {
230
+ const ids = [govCenterLayerId(layer), ...layer === "notifications" ? [AREAS_ID] : []];
231
+ for (const id of ids) {
232
+ if (map.getLayer(id)) map.setLayoutProperty(id, "visibility", visible ? "visible" : "none");
233
+ }
234
+ }
235
+
236
+ // src/create.ts
237
+ var THAILAND_CENTER = [100.99, 13.04];
238
+ function createGovMap(maplibregl, options) {
239
+ const map = new maplibregl.Map({
240
+ container: options.container,
241
+ style: freeStyle(options.basemap),
242
+ center: options.center ?? THAILAND_CENTER,
243
+ zoom: options.zoom ?? (options.center ? 13 : 5),
244
+ pitch: options.threeD ? TILTED_PITCH : 0,
245
+ maxPitch: 85,
246
+ ...options.mapOptions
247
+ });
248
+ map.addControl(new maplibregl.NavigationControl({ visualizePitch: true }), "top-right");
249
+ map.addControl(new maplibregl.ScaleControl({ unit: "metric" }), "bottom-left");
250
+ if (options.threeD) map.once("load", () => set3D(map, true));
251
+ return map;
252
+ }
253
+ // Annotate the CommonJS export names for ESM import in node:
254
+ 0 && (module.exports = {
255
+ DEM_SOURCE,
256
+ EMERGENCY_COLOR,
257
+ FREE_BASEMAPS,
258
+ HILLSHADE_LAYER,
259
+ LAYER_STYLE,
260
+ STATION_STYLE,
261
+ TERRAIN_EXAGGERATION,
262
+ THAILAND_CENTER,
263
+ TILTED_PITCH,
264
+ addGovCenterLayers,
265
+ circlePolygon,
266
+ createGovMap,
267
+ freeStyle,
268
+ govCenterLayerId,
269
+ layerColor,
270
+ notificationAreas,
271
+ set3D,
272
+ setBasemap,
273
+ setGovCenterLayerVisible
274
+ });
275
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/basemaps.ts","../src/three-d.ts","../src/govcenter.ts","../src/create.ts"],"sourcesContent":["export * from './basemaps';\r\nexport * from './three-d';\r\nexport * from './govcenter';\r\nexport * from './create';\r\n","import type { HillshadeLayerSpecification, Map, StyleSpecification } from 'maplibre-gl';\r\n\r\n/**\r\n * Free basemaps (satellite, topographic, streets) and elevation for 3D, as on the landslide\r\n * dashboard. Free tiles suit development and light use; a production e-service with heavy\r\n * traffic should serve its own or a paid provider's tiles.\r\n */\r\n\r\nexport type BasemapId = 'satellite' | 'topo' | 'streets';\r\n\r\n/** In the order a basemap picker shows them. */\r\nexport const FREE_BASEMAPS: { id: BasemapId; label: string }[] = [\r\n { id: 'satellite', label: 'ดาวเทียม' },\r\n { id: 'topo', label: 'ภูมิประเทศ' },\r\n { id: 'streets', label: 'ถนน' },\r\n];\r\n\r\nconst DEM_TILES = ['https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png'];\r\n\r\nexport const DEM_SOURCE = {\r\n type: 'raster-dem' as const,\r\n tiles: DEM_TILES,\r\n tileSize: 256,\r\n maxzoom: 15,\r\n encoding: 'terrarium' as const,\r\n};\r\n\r\nexport const HILLSHADE_LAYER: HillshadeLayerSpecification = {\r\n id: 'hillshade',\r\n type: 'hillshade',\r\n source: 'hillshadeDem',\r\n paint: { 'hillshade-exaggeration': 0.4, 'hillshade-shadow-color': '#0b1220' },\r\n};\r\n\r\n/** The style for `new maplibregl.Map({ style })`: every free basemap, satellite shown first. */\r\nexport function freeStyle(initial: BasemapId = 'satellite'): StyleSpecification {\r\n const visibility = (id: BasemapId) => (id === initial ? 'visible' : 'none') as 'visible' | 'none';\r\n return {\r\n version: 8,\r\n sources: {\r\n satellite: {\r\n type: 'raster',\r\n tiles: [\r\n 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',\r\n ],\r\n tileSize: 256,\r\n maxzoom: 18,\r\n attribution: 'Imagery © Esri, Maxar, Earthstar Geographics',\r\n },\r\n topo: {\r\n type: 'raster',\r\n tiles: ['a', 'b', 'c'].map((s) => `https://${s}.tile.opentopomap.org/{z}/{x}/{y}.png`),\r\n tileSize: 256,\r\n // OpenTopoMap is a volunteer server that throttles bursts; above z15 tiles are overzoomed.\r\n maxzoom: 15,\r\n attribution: '© OpenTopoMap (CC-BY-SA) © OpenStreetMap contributors',\r\n },\r\n streets: {\r\n type: 'raster',\r\n tiles: ['https://tile.openstreetmap.org/{z}/{x}/{y}.png'],\r\n tileSize: 256,\r\n maxzoom: 19,\r\n attribution: '© OpenStreetMap contributors',\r\n },\r\n // MapLibre recommends separate DEM sources for the 3D mesh and the hillshade.\r\n terrain: { ...DEM_SOURCE, attribution: 'Terrain: AWS Terrain Tiles (SRTM et al.)' },\r\n hillshadeDem: DEM_SOURCE,\r\n },\r\n layers: [\r\n { id: 'base-satellite', type: 'raster', source: 'satellite', layout: { visibility: visibility('satellite') } },\r\n { id: 'base-topo', type: 'raster', source: 'topo', layout: { visibility: visibility('topo') } },\r\n { id: 'base-streets', type: 'raster', source: 'streets', layout: { visibility: visibility('streets') } },\r\n HILLSHADE_LAYER,\r\n ],\r\n };\r\n}\r\n\r\n/** Shows one basemap of `freeStyle` and hides the others. */\r\nexport function setBasemap(map: Map, id: BasemapId) {\r\n for (const b of FREE_BASEMAPS) {\r\n map.setLayoutProperty(`base-${b.id}`, 'visibility', b.id === id ? 'visible' : 'none');\r\n }\r\n}\r\n","import type { Map } from 'maplibre-gl';\r\n\r\nexport const TERRAIN_EXAGGERATION = 1.5;\r\nexport const TILTED_PITCH = 60;\r\n\r\n/**\r\n * Terrain in relief and a tilted camera, or back to flat. Needs a raster-dem source named\r\n * `terrain` (as in `freeStyle`). Tilting only from zoom 9 keeps a country-wide view readable.\r\n */\r\nexport function set3D(\r\n map: Map,\r\n on: boolean,\r\n { exaggeration = TERRAIN_EXAGGERATION, source = 'terrain' } = {},\r\n) {\r\n map.setTerrain(on ? { source, exaggeration } : null);\r\n map.easeTo({\r\n pitch: on ? Math.max(map.getPitch(), map.getZoom() > 9 ? TILTED_PITCH : 0) : 0,\r\n bearing: on ? map.getBearing() : 0,\r\n duration: 600,\r\n });\r\n}\r\n","import type { FeatureCollection, Point, Polygon } from 'geojson';\r\nimport type { ExpressionSpecification, Map } from 'maplibre-gl';\r\n\r\n/**\r\n * The layers of GovCenter's central map (Core 5), as `GET /e-services/gis/map-data` returns them,\r\n * drawn with the colors every GovCenter map uses.\r\n */\r\n\r\nexport type GovCenterLayer =\r\n | 'home'\r\n | 'residences'\r\n | 'municipality'\r\n | 'stations'\r\n | 'notifications'\r\n | 'evaluations';\r\n\r\nexport type StationType =\r\n | 'EVACUATION_SITE'\r\n | 'OFFICE'\r\n | 'STATION'\r\n | 'SENSOR'\r\n | 'UAV'\r\n | 'CCTV'\r\n | 'SIREN'\r\n | 'OTHER';\r\n\r\n/** The body of `GET /e-services/gis/map-data`. */\r\nexport interface MapDataResponse {\r\n basemap?: { provider: string; style: string; accessToken: string | null; attribution: string };\r\n /** [minLng, minLat, maxLng, maxLat] of every point, null when there is none. */\r\n bounds: [number, number, number, number] | null;\r\n generatedAt?: string;\r\n layers: Partial<Record<GovCenterLayer, FeatureCollection<Point>>>;\r\n}\r\n\r\nexport const LAYER_STYLE: Record<GovCenterLayer, { label: string; color: string }> = {\r\n home: { label: 'บ้านของฉัน', color: '#e11d48' },\r\n residences: { label: 'บ้านในพื้นที่', color: '#0d9488' },\r\n municipality: { label: 'สำนักงานท้องถิ่น', color: '#4f46e5' },\r\n stations: { label: 'สถานีและอุปกรณ์', color: '#64748b' },\r\n notifications: { label: 'การแจ้งเตือน', color: '#d97706' },\r\n evaluations: { label: 'ความพึงพอใจ', color: '#ca8a04' },\r\n};\r\n\r\nexport const STATION_STYLE: Record<StationType, { label: string; color: string }> = {\r\n EVACUATION_SITE: { label: 'สถานที่อพยพ', color: '#16a34a' },\r\n OFFICE: { label: 'สำนักงาน', color: '#2563eb' },\r\n STATION: { label: 'สถานีตรวจวัด', color: '#0891b2' },\r\n SENSOR: { label: 'เซนเซอร์', color: '#7c3aed' },\r\n UAV: { label: 'อุปกรณ์เคลื่อนที่', color: '#ea580c' },\r\n CCTV: { label: 'CCTV', color: '#475569' },\r\n SIREN: { label: 'หอเตือนภัย', color: '#dc2626' },\r\n OTHER: { label: 'อื่น ๆ', color: '#64748b' },\r\n};\r\n\r\nexport const EMERGENCY_COLOR = '#dc2626';\r\n\r\n/** A circle of radiusKm around [lng, lat], as a polygon. */\r\nexport function circlePolygon(lng: number, lat: number, radiusKm: number): Polygon {\r\n const ring: [number, number][] = [];\r\n const dLat = radiusKm / 110.574;\r\n const dLng = radiusKm / (111.32 * Math.cos((lat * Math.PI) / 180));\r\n for (let i = 0; i <= 64; i++) {\r\n const a = (i / 64) * 2 * Math.PI;\r\n ring.push([lng + dLng * Math.cos(a), lat + dLat * Math.sin(a)]);\r\n }\r\n return { type: 'Polygon', coordinates: [ring] };\r\n}\r\n\r\n/** The fill of every area notification: a circle of its radius around its center. */\r\nexport function notificationAreas(notifications?: FeatureCollection<Point>): FeatureCollection<Polygon> {\r\n return {\r\n type: 'FeatureCollection',\r\n features: (notifications?.features ?? []).flatMap((f) => {\r\n const radiusKm = Number(f.properties?.radiusKm);\r\n if (!(radiusKm > 0)) return [];\r\n const [lng, lat] = f.geometry.coordinates;\r\n return [{ type: 'Feature', geometry: circlePolygon(lng, lat, radiusKm), properties: f.properties }];\r\n }),\r\n };\r\n}\r\n\r\n/** The circle color of a layer: stations by type, notifications red when they are emergencies. */\r\nexport function layerColor(layer: GovCenterLayer): string | ExpressionSpecification {\r\n if (layer === 'stations') {\r\n return [\r\n 'match',\r\n ['get', 'type'],\r\n ...Object.entries(STATION_STYLE).flatMap(([type, s]) => [type, s.color]),\r\n STATION_STYLE.OTHER.color,\r\n ] as unknown as ExpressionSpecification;\r\n }\r\n if (layer === 'notifications') {\r\n return ['case', ['==', ['get', 'emergency'], true], EMERGENCY_COLOR, LAYER_STYLE.notifications.color];\r\n }\r\n return LAYER_STYLE[layer].color;\r\n}\r\n\r\nexport const govCenterLayerId = (layer: GovCenterLayer) => `gc-${layer}`;\r\nconst AREAS_ID = 'gc-notification-areas';\r\n\r\nexport interface GovCenterLayerOptions {\r\n /** Called when a point is clicked, with its layer and properties. */\r\n onClick?: (layer: GovCenterLayer, properties: Record<string, unknown>, lngLat: { lng: number; lat: number }) => void;\r\n}\r\n\r\n/**\r\n * Draws every layer of a map-data response, or updates its data when already drawn. Call after\r\n * the map's `load` event. Returns the ids of the point layers it drew.\r\n */\r\nexport function addGovCenterLayers(map: Map, data: MapDataResponse, options: GovCenterLayerOptions = {}) {\r\n const ids: string[] = [];\r\n const areas = notificationAreas(data.layers.notifications);\r\n if (areas.features.length) {\r\n const existing = map.getSource(AREAS_ID) as { setData?: (d: unknown) => void } | undefined;\r\n if (existing?.setData) existing.setData(areas);\r\n else {\r\n map.addSource(AREAS_ID, { type: 'geojson', data: areas });\r\n map.addLayer({\r\n id: AREAS_ID,\r\n type: 'fill',\r\n source: AREAS_ID,\r\n paint: { 'fill-color': layerColor('notifications'), 'fill-opacity': 0.15 },\r\n });\r\n }\r\n }\r\n for (const [name, collection] of Object.entries(data.layers) as [GovCenterLayer, FeatureCollection<Point>][]) {\r\n if (!collection || !(name in LAYER_STYLE)) continue;\r\n const id = govCenterLayerId(name);\r\n ids.push(id);\r\n const existing = map.getSource(id) as { setData?: (d: unknown) => void } | undefined;\r\n if (existing?.setData) {\r\n existing.setData(collection);\r\n continue;\r\n }\r\n map.addSource(id, { type: 'geojson', data: collection });\r\n map.addLayer({\r\n id,\r\n type: 'circle',\r\n source: id,\r\n paint: {\r\n 'circle-radius': name === 'residences' ? 4 : 7,\r\n 'circle-color': layerColor(name),\r\n 'circle-stroke-color': '#ffffff',\r\n 'circle-stroke-width': 2,\r\n },\r\n });\r\n if (options.onClick) {\r\n map.on('click', id, (e) => {\r\n const f = e.features?.[0];\r\n if (f) options.onClick?.(name, f.properties ?? {}, e.lngLat);\r\n });\r\n map.on('mouseenter', id, () => (map.getCanvas().style.cursor = 'pointer'));\r\n map.on('mouseleave', id, () => (map.getCanvas().style.cursor = ''));\r\n }\r\n }\r\n return ids;\r\n}\r\n\r\n/** Shows or hides one GovCenter layer (and the notification areas with the notifications). */\r\nexport function setGovCenterLayerVisible(map: Map, layer: GovCenterLayer, visible: boolean) {\r\n const ids = [govCenterLayerId(layer), ...(layer === 'notifications' ? [AREAS_ID] : [])];\r\n for (const id of ids) {\r\n if (map.getLayer(id)) map.setLayoutProperty(id, 'visibility', visible ? 'visible' : 'none');\r\n }\r\n}\r\n","import type { LngLatLike, Map, MapOptions } from 'maplibre-gl';\r\nimport { type BasemapId, freeStyle } from './basemaps';\r\nimport { set3D, TILTED_PITCH } from './three-d';\r\n\r\n/** Thailand, for a map that opens without a center. */\r\nexport const THAILAND_CENTER: [number, number] = [100.99, 13.04];\r\n\r\nexport interface GovMapOptions {\r\n container: HTMLElement | string;\r\n center?: LngLatLike;\r\n zoom?: number;\r\n /** Open with the terrain in relief, tilted. */\r\n threeD?: boolean;\r\n basemap?: BasemapId;\r\n /** Anything else MapLibre takes; wins over the defaults above. */\r\n mapOptions?: Partial<MapOptions>;\r\n}\r\n\r\n/** The MapLibre module, passed in so this package never bundles it: `import maplibregl from 'maplibre-gl'`. */\r\nexport interface MapLibreModule {\r\n Map: new (options: MapOptions) => Map;\r\n NavigationControl: new (options?: { visualizePitch?: boolean; showCompass?: boolean }) => unknown;\r\n ScaleControl: new (options?: { unit?: 'metric' }) => unknown;\r\n}\r\n\r\n/**\r\n * A map that moves like Google Maps: drag to pan, scroll to zoom, right-drag or two fingers to\r\n * tilt and rotate, with zoom/compass buttons and a scale bar. The free basemaps and terrain are\r\n * in its style, so `set3D` and `setBasemap` work right away.\r\n */\r\nexport function createGovMap(maplibregl: MapLibreModule, options: GovMapOptions): Map {\r\n const map = new maplibregl.Map({\r\n container: options.container,\r\n style: freeStyle(options.basemap),\r\n center: options.center ?? THAILAND_CENTER,\r\n zoom: options.zoom ?? (options.center ? 13 : 5),\r\n pitch: options.threeD ? TILTED_PITCH : 0,\r\n maxPitch: 85,\r\n ...options.mapOptions,\r\n } as MapOptions);\r\n map.addControl(new maplibregl.NavigationControl({ visualizePitch: true }) as never, 'top-right');\r\n map.addControl(new maplibregl.ScaleControl({ unit: 'metric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;AAAA,IAChC,QAAQ,QAAQ,UAAU;AAAA,IAC1B,MAAM,QAAQ,SAAS,QAAQ,SAAS,KAAK;AAAA,IAC7C,OAAO,QAAQ,SAAS,eAAe;AAAA,IACvC,UAAU;AAAA,IACV,GAAG,QAAQ;AAAA,EACb,CAAe;AACf,MAAI,WAAW,IAAI,WAAW,kBAAkB,EAAE,gBAAgB,KAAK,CAAC,GAAY,WAAW;AAC/F,MAAI,WAAW,IAAI,WAAW,aAAa,EAAE,MAAM,SAAS,CAAC,GAAY,aAAa;AACtF,MAAI,QAAQ,OAAQ,KAAI,KAAK,QAAQ,MAAM,MAAM,KAAK,IAAI,CAAC;AAC3D,SAAO;AACT;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,230 @@
1
+ // src/basemaps.ts
2
+ var FREE_BASEMAPS = [
3
+ { id: "satellite", label: "\u0E14\u0E32\u0E27\u0E40\u0E17\u0E35\u0E22\u0E21" },
4
+ { id: "topo", label: "\u0E20\u0E39\u0E21\u0E34\u0E1B\u0E23\u0E30\u0E40\u0E17\u0E28" },
5
+ { id: "streets", label: "\u0E16\u0E19\u0E19" }
6
+ ];
7
+ var DEM_TILES = ["https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"];
8
+ var DEM_SOURCE = {
9
+ type: "raster-dem",
10
+ tiles: DEM_TILES,
11
+ tileSize: 256,
12
+ maxzoom: 15,
13
+ encoding: "terrarium"
14
+ };
15
+ var HILLSHADE_LAYER = {
16
+ id: "hillshade",
17
+ type: "hillshade",
18
+ source: "hillshadeDem",
19
+ paint: { "hillshade-exaggeration": 0.4, "hillshade-shadow-color": "#0b1220" }
20
+ };
21
+ function freeStyle(initial = "satellite") {
22
+ const visibility = (id) => id === initial ? "visible" : "none";
23
+ return {
24
+ version: 8,
25
+ sources: {
26
+ satellite: {
27
+ type: "raster",
28
+ tiles: [
29
+ "https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
30
+ ],
31
+ tileSize: 256,
32
+ maxzoom: 18,
33
+ attribution: "Imagery \xA9 Esri, Maxar, Earthstar Geographics"
34
+ },
35
+ topo: {
36
+ type: "raster",
37
+ tiles: ["a", "b", "c"].map((s) => `https://${s}.tile.opentopomap.org/{z}/{x}/{y}.png`),
38
+ tileSize: 256,
39
+ // OpenTopoMap is a volunteer server that throttles bursts; above z15 tiles are overzoomed.
40
+ maxzoom: 15,
41
+ attribution: "\xA9 OpenTopoMap (CC-BY-SA) \xA9 OpenStreetMap contributors"
42
+ },
43
+ streets: {
44
+ type: "raster",
45
+ tiles: ["https://tile.openstreetmap.org/{z}/{x}/{y}.png"],
46
+ tileSize: 256,
47
+ maxzoom: 19,
48
+ attribution: "\xA9 OpenStreetMap contributors"
49
+ },
50
+ // MapLibre recommends separate DEM sources for the 3D mesh and the hillshade.
51
+ terrain: { ...DEM_SOURCE, attribution: "Terrain: AWS Terrain Tiles (SRTM et al.)" },
52
+ hillshadeDem: DEM_SOURCE
53
+ },
54
+ layers: [
55
+ { id: "base-satellite", type: "raster", source: "satellite", layout: { visibility: visibility("satellite") } },
56
+ { id: "base-topo", type: "raster", source: "topo", layout: { visibility: visibility("topo") } },
57
+ { id: "base-streets", type: "raster", source: "streets", layout: { visibility: visibility("streets") } },
58
+ HILLSHADE_LAYER
59
+ ]
60
+ };
61
+ }
62
+ function setBasemap(map, id) {
63
+ for (const b of FREE_BASEMAPS) {
64
+ map.setLayoutProperty(`base-${b.id}`, "visibility", b.id === id ? "visible" : "none");
65
+ }
66
+ }
67
+
68
+ // src/three-d.ts
69
+ var TERRAIN_EXAGGERATION = 1.5;
70
+ var TILTED_PITCH = 60;
71
+ function set3D(map, on, { exaggeration = TERRAIN_EXAGGERATION, source = "terrain" } = {}) {
72
+ map.setTerrain(on ? { source, exaggeration } : null);
73
+ map.easeTo({
74
+ pitch: on ? Math.max(map.getPitch(), map.getZoom() > 9 ? TILTED_PITCH : 0) : 0,
75
+ bearing: on ? map.getBearing() : 0,
76
+ duration: 600
77
+ });
78
+ }
79
+
80
+ // src/govcenter.ts
81
+ var LAYER_STYLE = {
82
+ home: { label: "\u0E1A\u0E49\u0E32\u0E19\u0E02\u0E2D\u0E07\u0E09\u0E31\u0E19", color: "#e11d48" },
83
+ residences: { label: "\u0E1A\u0E49\u0E32\u0E19\u0E43\u0E19\u0E1E\u0E37\u0E49\u0E19\u0E17\u0E35\u0E48", color: "#0d9488" },
84
+ municipality: { label: "\u0E2A\u0E33\u0E19\u0E31\u0E01\u0E07\u0E32\u0E19\u0E17\u0E49\u0E2D\u0E07\u0E16\u0E34\u0E48\u0E19", color: "#4f46e5" },
85
+ stations: { label: "\u0E2A\u0E16\u0E32\u0E19\u0E35\u0E41\u0E25\u0E30\u0E2D\u0E38\u0E1B\u0E01\u0E23\u0E13\u0E4C", color: "#64748b" },
86
+ notifications: { label: "\u0E01\u0E32\u0E23\u0E41\u0E08\u0E49\u0E07\u0E40\u0E15\u0E37\u0E2D\u0E19", color: "#d97706" },
87
+ evaluations: { label: "\u0E04\u0E27\u0E32\u0E21\u0E1E\u0E36\u0E07\u0E1E\u0E2D\u0E43\u0E08", color: "#ca8a04" }
88
+ };
89
+ var STATION_STYLE = {
90
+ EVACUATION_SITE: { label: "\u0E2A\u0E16\u0E32\u0E19\u0E17\u0E35\u0E48\u0E2D\u0E1E\u0E22\u0E1E", color: "#16a34a" },
91
+ OFFICE: { label: "\u0E2A\u0E33\u0E19\u0E31\u0E01\u0E07\u0E32\u0E19", color: "#2563eb" },
92
+ STATION: { label: "\u0E2A\u0E16\u0E32\u0E19\u0E35\u0E15\u0E23\u0E27\u0E08\u0E27\u0E31\u0E14", color: "#0891b2" },
93
+ SENSOR: { label: "\u0E40\u0E0B\u0E19\u0E40\u0E0B\u0E2D\u0E23\u0E4C", color: "#7c3aed" },
94
+ UAV: { label: "\u0E2D\u0E38\u0E1B\u0E01\u0E23\u0E13\u0E4C\u0E40\u0E04\u0E25\u0E37\u0E48\u0E2D\u0E19\u0E17\u0E35\u0E48", color: "#ea580c" },
95
+ CCTV: { label: "CCTV", color: "#475569" },
96
+ SIREN: { label: "\u0E2B\u0E2D\u0E40\u0E15\u0E37\u0E2D\u0E19\u0E20\u0E31\u0E22", color: "#dc2626" },
97
+ OTHER: { label: "\u0E2D\u0E37\u0E48\u0E19 \u0E46", color: "#64748b" }
98
+ };
99
+ var EMERGENCY_COLOR = "#dc2626";
100
+ function circlePolygon(lng, lat, radiusKm) {
101
+ const ring = [];
102
+ const dLat = radiusKm / 110.574;
103
+ const dLng = radiusKm / (111.32 * Math.cos(lat * Math.PI / 180));
104
+ for (let i = 0; i <= 64; i++) {
105
+ const a = i / 64 * 2 * Math.PI;
106
+ ring.push([lng + dLng * Math.cos(a), lat + dLat * Math.sin(a)]);
107
+ }
108
+ return { type: "Polygon", coordinates: [ring] };
109
+ }
110
+ function notificationAreas(notifications) {
111
+ return {
112
+ type: "FeatureCollection",
113
+ features: (notifications?.features ?? []).flatMap((f) => {
114
+ const radiusKm = Number(f.properties?.radiusKm);
115
+ if (!(radiusKm > 0)) return [];
116
+ const [lng, lat] = f.geometry.coordinates;
117
+ return [{ type: "Feature", geometry: circlePolygon(lng, lat, radiusKm), properties: f.properties }];
118
+ })
119
+ };
120
+ }
121
+ function layerColor(layer) {
122
+ if (layer === "stations") {
123
+ return [
124
+ "match",
125
+ ["get", "type"],
126
+ ...Object.entries(STATION_STYLE).flatMap(([type, s]) => [type, s.color]),
127
+ STATION_STYLE.OTHER.color
128
+ ];
129
+ }
130
+ if (layer === "notifications") {
131
+ return ["case", ["==", ["get", "emergency"], true], EMERGENCY_COLOR, LAYER_STYLE.notifications.color];
132
+ }
133
+ return LAYER_STYLE[layer].color;
134
+ }
135
+ var govCenterLayerId = (layer) => `gc-${layer}`;
136
+ var AREAS_ID = "gc-notification-areas";
137
+ function addGovCenterLayers(map, data, options = {}) {
138
+ const ids = [];
139
+ const areas = notificationAreas(data.layers.notifications);
140
+ if (areas.features.length) {
141
+ const existing = map.getSource(AREAS_ID);
142
+ if (existing?.setData) existing.setData(areas);
143
+ else {
144
+ map.addSource(AREAS_ID, { type: "geojson", data: areas });
145
+ map.addLayer({
146
+ id: AREAS_ID,
147
+ type: "fill",
148
+ source: AREAS_ID,
149
+ paint: { "fill-color": layerColor("notifications"), "fill-opacity": 0.15 }
150
+ });
151
+ }
152
+ }
153
+ for (const [name, collection] of Object.entries(data.layers)) {
154
+ if (!collection || !(name in LAYER_STYLE)) continue;
155
+ const id = govCenterLayerId(name);
156
+ ids.push(id);
157
+ const existing = map.getSource(id);
158
+ if (existing?.setData) {
159
+ existing.setData(collection);
160
+ continue;
161
+ }
162
+ map.addSource(id, { type: "geojson", data: collection });
163
+ map.addLayer({
164
+ id,
165
+ type: "circle",
166
+ source: id,
167
+ paint: {
168
+ "circle-radius": name === "residences" ? 4 : 7,
169
+ "circle-color": layerColor(name),
170
+ "circle-stroke-color": "#ffffff",
171
+ "circle-stroke-width": 2
172
+ }
173
+ });
174
+ if (options.onClick) {
175
+ map.on("click", id, (e) => {
176
+ const f = e.features?.[0];
177
+ if (f) options.onClick?.(name, f.properties ?? {}, e.lngLat);
178
+ });
179
+ map.on("mouseenter", id, () => map.getCanvas().style.cursor = "pointer");
180
+ map.on("mouseleave", id, () => map.getCanvas().style.cursor = "");
181
+ }
182
+ }
183
+ return ids;
184
+ }
185
+ function setGovCenterLayerVisible(map, layer, visible) {
186
+ const ids = [govCenterLayerId(layer), ...layer === "notifications" ? [AREAS_ID] : []];
187
+ for (const id of ids) {
188
+ if (map.getLayer(id)) map.setLayoutProperty(id, "visibility", visible ? "visible" : "none");
189
+ }
190
+ }
191
+
192
+ // src/create.ts
193
+ var THAILAND_CENTER = [100.99, 13.04];
194
+ function createGovMap(maplibregl, options) {
195
+ const map = new maplibregl.Map({
196
+ container: options.container,
197
+ style: freeStyle(options.basemap),
198
+ center: options.center ?? THAILAND_CENTER,
199
+ zoom: options.zoom ?? (options.center ? 13 : 5),
200
+ pitch: options.threeD ? TILTED_PITCH : 0,
201
+ maxPitch: 85,
202
+ ...options.mapOptions
203
+ });
204
+ map.addControl(new maplibregl.NavigationControl({ visualizePitch: true }), "top-right");
205
+ map.addControl(new maplibregl.ScaleControl({ unit: "metric" }), "bottom-left");
206
+ if (options.threeD) map.once("load", () => set3D(map, true));
207
+ return map;
208
+ }
209
+ export {
210
+ DEM_SOURCE,
211
+ EMERGENCY_COLOR,
212
+ FREE_BASEMAPS,
213
+ HILLSHADE_LAYER,
214
+ LAYER_STYLE,
215
+ STATION_STYLE,
216
+ TERRAIN_EXAGGERATION,
217
+ THAILAND_CENTER,
218
+ TILTED_PITCH,
219
+ addGovCenterLayers,
220
+ circlePolygon,
221
+ createGovMap,
222
+ freeStyle,
223
+ govCenterLayerId,
224
+ layerColor,
225
+ notificationAreas,
226
+ set3D,
227
+ setBasemap,
228
+ setGovCenterLayerVisible
229
+ };
230
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/basemaps.ts","../src/three-d.ts","../src/govcenter.ts","../src/create.ts"],"sourcesContent":["import type { HillshadeLayerSpecification, Map, StyleSpecification } from 'maplibre-gl';\r\n\r\n/**\r\n * Free basemaps (satellite, topographic, streets) and elevation for 3D, as on the landslide\r\n * dashboard. Free tiles suit development and light use; a production e-service with heavy\r\n * traffic should serve its own or a paid provider's tiles.\r\n */\r\n\r\nexport type BasemapId = 'satellite' | 'topo' | 'streets';\r\n\r\n/** In the order a basemap picker shows them. */\r\nexport const FREE_BASEMAPS: { id: BasemapId; label: string }[] = [\r\n { id: 'satellite', label: 'ดาวเทียม' },\r\n { id: 'topo', label: 'ภูมิประเทศ' },\r\n { id: 'streets', label: 'ถนน' },\r\n];\r\n\r\nconst DEM_TILES = ['https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png'];\r\n\r\nexport const DEM_SOURCE = {\r\n type: 'raster-dem' as const,\r\n tiles: DEM_TILES,\r\n tileSize: 256,\r\n maxzoom: 15,\r\n encoding: 'terrarium' as const,\r\n};\r\n\r\nexport const HILLSHADE_LAYER: HillshadeLayerSpecification = {\r\n id: 'hillshade',\r\n type: 'hillshade',\r\n source: 'hillshadeDem',\r\n paint: { 'hillshade-exaggeration': 0.4, 'hillshade-shadow-color': '#0b1220' },\r\n};\r\n\r\n/** The style for `new maplibregl.Map({ style })`: every free basemap, satellite shown first. */\r\nexport function freeStyle(initial: BasemapId = 'satellite'): StyleSpecification {\r\n const visibility = (id: BasemapId) => (id === initial ? 'visible' : 'none') as 'visible' | 'none';\r\n return {\r\n version: 8,\r\n sources: {\r\n satellite: {\r\n type: 'raster',\r\n tiles: [\r\n 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',\r\n ],\r\n tileSize: 256,\r\n maxzoom: 18,\r\n attribution: 'Imagery © Esri, Maxar, Earthstar Geographics',\r\n },\r\n topo: {\r\n type: 'raster',\r\n tiles: ['a', 'b', 'c'].map((s) => `https://${s}.tile.opentopomap.org/{z}/{x}/{y}.png`),\r\n tileSize: 256,\r\n // OpenTopoMap is a volunteer server that throttles bursts; above z15 tiles are overzoomed.\r\n maxzoom: 15,\r\n attribution: '© OpenTopoMap (CC-BY-SA) © OpenStreetMap contributors',\r\n },\r\n streets: {\r\n type: 'raster',\r\n tiles: ['https://tile.openstreetmap.org/{z}/{x}/{y}.png'],\r\n tileSize: 256,\r\n maxzoom: 19,\r\n attribution: '© OpenStreetMap contributors',\r\n },\r\n // MapLibre recommends separate DEM sources for the 3D mesh and the hillshade.\r\n terrain: { ...DEM_SOURCE, attribution: 'Terrain: AWS Terrain Tiles (SRTM et al.)' },\r\n hillshadeDem: DEM_SOURCE,\r\n },\r\n layers: [\r\n { id: 'base-satellite', type: 'raster', source: 'satellite', layout: { visibility: visibility('satellite') } },\r\n { id: 'base-topo', type: 'raster', source: 'topo', layout: { visibility: visibility('topo') } },\r\n { id: 'base-streets', type: 'raster', source: 'streets', layout: { visibility: visibility('streets') } },\r\n HILLSHADE_LAYER,\r\n ],\r\n };\r\n}\r\n\r\n/** Shows one basemap of `freeStyle` and hides the others. */\r\nexport function setBasemap(map: Map, id: BasemapId) {\r\n for (const b of FREE_BASEMAPS) {\r\n map.setLayoutProperty(`base-${b.id}`, 'visibility', b.id === id ? 'visible' : 'none');\r\n }\r\n}\r\n","import type { Map } from 'maplibre-gl';\r\n\r\nexport const TERRAIN_EXAGGERATION = 1.5;\r\nexport const TILTED_PITCH = 60;\r\n\r\n/**\r\n * Terrain in relief and a tilted camera, or back to flat. Needs a raster-dem source named\r\n * `terrain` (as in `freeStyle`). Tilting only from zoom 9 keeps a country-wide view readable.\r\n */\r\nexport function set3D(\r\n map: Map,\r\n on: boolean,\r\n { exaggeration = TERRAIN_EXAGGERATION, source = 'terrain' } = {},\r\n) {\r\n map.setTerrain(on ? { source, exaggeration } : null);\r\n map.easeTo({\r\n pitch: on ? Math.max(map.getPitch(), map.getZoom() > 9 ? TILTED_PITCH : 0) : 0,\r\n bearing: on ? map.getBearing() : 0,\r\n duration: 600,\r\n });\r\n}\r\n","import type { FeatureCollection, Point, Polygon } from 'geojson';\r\nimport type { ExpressionSpecification, Map } from 'maplibre-gl';\r\n\r\n/**\r\n * The layers of GovCenter's central map (Core 5), as `GET /e-services/gis/map-data` returns them,\r\n * drawn with the colors every GovCenter map uses.\r\n */\r\n\r\nexport type GovCenterLayer =\r\n | 'home'\r\n | 'residences'\r\n | 'municipality'\r\n | 'stations'\r\n | 'notifications'\r\n | 'evaluations';\r\n\r\nexport type StationType =\r\n | 'EVACUATION_SITE'\r\n | 'OFFICE'\r\n | 'STATION'\r\n | 'SENSOR'\r\n | 'UAV'\r\n | 'CCTV'\r\n | 'SIREN'\r\n | 'OTHER';\r\n\r\n/** The body of `GET /e-services/gis/map-data`. */\r\nexport interface MapDataResponse {\r\n basemap?: { provider: string; style: string; accessToken: string | null; attribution: string };\r\n /** [minLng, minLat, maxLng, maxLat] of every point, null when there is none. */\r\n bounds: [number, number, number, number] | null;\r\n generatedAt?: string;\r\n layers: Partial<Record<GovCenterLayer, FeatureCollection<Point>>>;\r\n}\r\n\r\nexport const LAYER_STYLE: Record<GovCenterLayer, { label: string; color: string }> = {\r\n home: { label: 'บ้านของฉัน', color: '#e11d48' },\r\n residences: { label: 'บ้านในพื้นที่', color: '#0d9488' },\r\n municipality: { label: 'สำนักงานท้องถิ่น', color: '#4f46e5' },\r\n stations: { label: 'สถานีและอุปกรณ์', color: '#64748b' },\r\n notifications: { label: 'การแจ้งเตือน', color: '#d97706' },\r\n evaluations: { label: 'ความพึงพอใจ', color: '#ca8a04' },\r\n};\r\n\r\nexport const STATION_STYLE: Record<StationType, { label: string; color: string }> = {\r\n EVACUATION_SITE: { label: 'สถานที่อพยพ', color: '#16a34a' },\r\n OFFICE: { label: 'สำนักงาน', color: '#2563eb' },\r\n STATION: { label: 'สถานีตรวจวัด', color: '#0891b2' },\r\n SENSOR: { label: 'เซนเซอร์', color: '#7c3aed' },\r\n UAV: { label: 'อุปกรณ์เคลื่อนที่', color: '#ea580c' },\r\n CCTV: { label: 'CCTV', color: '#475569' },\r\n SIREN: { label: 'หอเตือนภัย', color: '#dc2626' },\r\n OTHER: { label: 'อื่น ๆ', color: '#64748b' },\r\n};\r\n\r\nexport const EMERGENCY_COLOR = '#dc2626';\r\n\r\n/** A circle of radiusKm around [lng, lat], as a polygon. */\r\nexport function circlePolygon(lng: number, lat: number, radiusKm: number): Polygon {\r\n const ring: [number, number][] = [];\r\n const dLat = radiusKm / 110.574;\r\n const dLng = radiusKm / (111.32 * Math.cos((lat * Math.PI) / 180));\r\n for (let i = 0; i <= 64; i++) {\r\n const a = (i / 64) * 2 * Math.PI;\r\n ring.push([lng + dLng * Math.cos(a), lat + dLat * Math.sin(a)]);\r\n }\r\n return { type: 'Polygon', coordinates: [ring] };\r\n}\r\n\r\n/** The fill of every area notification: a circle of its radius around its center. */\r\nexport function notificationAreas(notifications?: FeatureCollection<Point>): FeatureCollection<Polygon> {\r\n return {\r\n type: 'FeatureCollection',\r\n features: (notifications?.features ?? []).flatMap((f) => {\r\n const radiusKm = Number(f.properties?.radiusKm);\r\n if (!(radiusKm > 0)) return [];\r\n const [lng, lat] = f.geometry.coordinates;\r\n return [{ type: 'Feature', geometry: circlePolygon(lng, lat, radiusKm), properties: f.properties }];\r\n }),\r\n };\r\n}\r\n\r\n/** The circle color of a layer: stations by type, notifications red when they are emergencies. */\r\nexport function layerColor(layer: GovCenterLayer): string | ExpressionSpecification {\r\n if (layer === 'stations') {\r\n return [\r\n 'match',\r\n ['get', 'type'],\r\n ...Object.entries(STATION_STYLE).flatMap(([type, s]) => [type, s.color]),\r\n STATION_STYLE.OTHER.color,\r\n ] as unknown as ExpressionSpecification;\r\n }\r\n if (layer === 'notifications') {\r\n return ['case', ['==', ['get', 'emergency'], true], EMERGENCY_COLOR, LAYER_STYLE.notifications.color];\r\n }\r\n return LAYER_STYLE[layer].color;\r\n}\r\n\r\nexport const govCenterLayerId = (layer: GovCenterLayer) => `gc-${layer}`;\r\nconst AREAS_ID = 'gc-notification-areas';\r\n\r\nexport interface GovCenterLayerOptions {\r\n /** Called when a point is clicked, with its layer and properties. */\r\n onClick?: (layer: GovCenterLayer, properties: Record<string, unknown>, lngLat: { lng: number; lat: number }) => void;\r\n}\r\n\r\n/**\r\n * Draws every layer of a map-data response, or updates its data when already drawn. Call after\r\n * the map's `load` event. Returns the ids of the point layers it drew.\r\n */\r\nexport function addGovCenterLayers(map: Map, data: MapDataResponse, options: GovCenterLayerOptions = {}) {\r\n const ids: string[] = [];\r\n const areas = notificationAreas(data.layers.notifications);\r\n if (areas.features.length) {\r\n const existing = map.getSource(AREAS_ID) as { setData?: (d: unknown) => void } | undefined;\r\n if (existing?.setData) existing.setData(areas);\r\n else {\r\n map.addSource(AREAS_ID, { type: 'geojson', data: areas });\r\n map.addLayer({\r\n id: AREAS_ID,\r\n type: 'fill',\r\n source: AREAS_ID,\r\n paint: { 'fill-color': layerColor('notifications'), 'fill-opacity': 0.15 },\r\n });\r\n }\r\n }\r\n for (const [name, collection] of Object.entries(data.layers) as [GovCenterLayer, FeatureCollection<Point>][]) {\r\n if (!collection || !(name in LAYER_STYLE)) continue;\r\n const id = govCenterLayerId(name);\r\n ids.push(id);\r\n const existing = map.getSource(id) as { setData?: (d: unknown) => void } | undefined;\r\n if (existing?.setData) {\r\n existing.setData(collection);\r\n continue;\r\n }\r\n map.addSource(id, { type: 'geojson', data: collection });\r\n map.addLayer({\r\n id,\r\n type: 'circle',\r\n source: id,\r\n paint: {\r\n 'circle-radius': name === 'residences' ? 4 : 7,\r\n 'circle-color': layerColor(name),\r\n 'circle-stroke-color': '#ffffff',\r\n 'circle-stroke-width': 2,\r\n },\r\n });\r\n if (options.onClick) {\r\n map.on('click', id, (e) => {\r\n const f = e.features?.[0];\r\n if (f) options.onClick?.(name, f.properties ?? {}, e.lngLat);\r\n });\r\n map.on('mouseenter', id, () => (map.getCanvas().style.cursor = 'pointer'));\r\n map.on('mouseleave', id, () => (map.getCanvas().style.cursor = ''));\r\n }\r\n }\r\n return ids;\r\n}\r\n\r\n/** Shows or hides one GovCenter layer (and the notification areas with the notifications). */\r\nexport function setGovCenterLayerVisible(map: Map, layer: GovCenterLayer, visible: boolean) {\r\n const ids = [govCenterLayerId(layer), ...(layer === 'notifications' ? [AREAS_ID] : [])];\r\n for (const id of ids) {\r\n if (map.getLayer(id)) map.setLayoutProperty(id, 'visibility', visible ? 'visible' : 'none');\r\n }\r\n}\r\n","import type { LngLatLike, Map, MapOptions } from 'maplibre-gl';\r\nimport { type BasemapId, freeStyle } from './basemaps';\r\nimport { set3D, TILTED_PITCH } from './three-d';\r\n\r\n/** Thailand, for a map that opens without a center. */\r\nexport const THAILAND_CENTER: [number, number] = [100.99, 13.04];\r\n\r\nexport interface GovMapOptions {\r\n container: HTMLElement | string;\r\n center?: LngLatLike;\r\n zoom?: number;\r\n /** Open with the terrain in relief, tilted. */\r\n threeD?: boolean;\r\n basemap?: BasemapId;\r\n /** Anything else MapLibre takes; wins over the defaults above. */\r\n mapOptions?: Partial<MapOptions>;\r\n}\r\n\r\n/** The MapLibre module, passed in so this package never bundles it: `import maplibregl from 'maplibre-gl'`. */\r\nexport interface MapLibreModule {\r\n Map: new (options: MapOptions) => Map;\r\n NavigationControl: new (options?: { visualizePitch?: boolean; showCompass?: boolean }) => unknown;\r\n ScaleControl: new (options?: { unit?: 'metric' }) => unknown;\r\n}\r\n\r\n/**\r\n * A map that moves like Google Maps: drag to pan, scroll to zoom, right-drag or two fingers to\r\n * tilt and rotate, with zoom/compass buttons and a scale bar. The free basemaps and terrain are\r\n * in its style, so `set3D` and `setBasemap` work right away.\r\n */\r\nexport function createGovMap(maplibregl: MapLibreModule, options: GovMapOptions): Map {\r\n const map = new maplibregl.Map({\r\n container: options.container,\r\n style: freeStyle(options.basemap),\r\n center: options.center ?? THAILAND_CENTER,\r\n zoom: options.zoom ?? (options.center ? 13 : 5),\r\n pitch: options.threeD ? TILTED_PITCH : 0,\r\n maxPitch: 85,\r\n ...options.mapOptions,\r\n } as MapOptions);\r\n map.addControl(new maplibregl.NavigationControl({ visualizePitch: true }) as never, 'top-right');\r\n map.addControl(new maplibregl.ScaleControl({ unit: 'metric' }) as never, 'bottom-left');\r\n if (options.threeD) map.once('load', () => set3D(map, true));\r\n return map;\r\n}\r\n"],"mappings":";AAWO,IAAM,gBAAoD;AAAA,EAC/D,EAAE,IAAI,aAAa,OAAO,mDAAW;AAAA,EACrC,EAAE,IAAI,QAAQ,OAAO,+DAAa;AAAA,EAClC,EAAE,IAAI,WAAW,OAAO,qBAAM;AAChC;AAEA,IAAM,YAAY,CAAC,yEAAyE;AAErF,IAAM,aAAa;AAAA,EACxB,MAAM;AAAA,EACN,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS;AAAA,EACT,UAAU;AACZ;AAEO,IAAM,kBAA+C;AAAA,EAC1D,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,OAAO,EAAE,0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AAO,IAAI,UAAU,EAAE,MAAM,SAAS,SAAU;AACzE,UAAI,GAAG,cAAc,IAAI,MAAO,IAAI,UAAU,EAAE,MAAM,SAAS,EAAG;AAAA,IACpE;AAAA,EACF;AACA,SAAO;AACT;AAGO,SAAS,yBAAyB,KAAU,OAAuB,SAAkB;AAC1F,QAAM,MAAM,CAAC,iBAAiB,KAAK,GAAG,GAAI,UAAU,kBAAkB,CAAC,QAAQ,IAAI,CAAC,CAAE;AACtF,aAAW,MAAM,KAAK;AACpB,QAAI,IAAI,SAAS,EAAE,EAAG,KAAI,kBAAkB,IAAI,cAAc,UAAU,YAAY,MAAM;AAAA,EAC5F;AACF;;;AChKO,IAAM,kBAAoC,CAAC,QAAQ,KAAK;AAyBxD,SAAS,aAAa,YAA4B,SAA6B;AACpF,QAAM,MAAM,IAAI,WAAW,IAAI;AAAA,IAC7B,WAAW,QAAQ;AAAA,IACnB,OAAO,UAAU,QAAQ,OAAO;AAAA,IAChC,QAAQ,QAAQ,UAAU;AAAA,IAC1B,MAAM,QAAQ,SAAS,QAAQ,SAAS,KAAK;AAAA,IAC7C,OAAO,QAAQ,SAAS,eAAe;AAAA,IACvC,UAAU;AAAA,IACV,GAAG,QAAQ;AAAA,EACb,CAAe;AACf,MAAI,WAAW,IAAI,WAAW,kBAAkB,EAAE,gBAAgB,KAAK,CAAC,GAAY,WAAW;AAC/F,MAAI,WAAW,IAAI,WAAW,aAAa,EAAE,MAAM,SAAS,CAAC,GAAY,aAAa;AACtF,MAAI,QAAQ,OAAQ,KAAI,KAAK,QAAQ,MAAM,MAAM,KAAK,IAAI,CAAC;AAC3D,SAAO;AACT;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,47 @@
1
1
  {
2
2
  "name": "@biza-gov/map",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "GovCenter map pieces for MapLibre: free basemaps, 3D terrain, and the central map (Core 5) layers with standard colors",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md"
18
+ ],
19
+ "scripts": {
20
+ "build": "tsup",
21
+ "dev": "tsup --watch",
22
+ "test": "npm run build && node __tests__/gov-map.test.mjs",
23
+ "prepublishOnly": "npm run build"
24
+ },
25
+ "keywords": [
26
+ "gov-center",
27
+ "map",
28
+ "maplibre",
29
+ "gis",
30
+ "3d",
31
+ "terrain"
32
+ ],
33
+ "license": "MIT",
34
+ "publishConfig": {
35
+ "access": "public",
36
+ "tag": "latest"
37
+ },
38
+ "peerDependencies": {
39
+ "maplibre-gl": ">=5"
40
+ },
41
+ "devDependencies": {
42
+ "@types/geojson": "7946.0.16",
43
+ "maplibre-gl": "6.14.0",
44
+ "tsup": "^8.0.0",
45
+ "typescript": "^5.0.0"
46
+ }
47
+ }