@file-viewer/renderer-geo 3.1.2 → 3.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.
package/README.en.md CHANGED
@@ -1,109 +1,7 @@
1
1
  # @file-viewer/renderer-geo
2
2
 
3
- Standalone geospatial renderer package for Flyfish File Viewer. It previews GeoJSON, KML, GPX, and Shapefile data in the browser while keeping `@tmcw/togeojson`, `shpjs`, `maplibre-gl`, and `proj4` lazy-loaded for geospatial files only.
3
+ Runtime package version 3.2.0.
4
4
 
5
- ## Usage
5
+ Usage and API documentation: https://doc.file-viewer.app/guide/on-demand-renderers
6
6
 
7
- ```ts
8
- import { geoRenderer } from '@file-viewer/renderer-geo'
9
-
10
- const options = {
11
- builtinRenderers: 'none',
12
- renderers: [geoRenderer],
13
- }
14
- ```
15
-
16
- You can also compose it through the full preset:
17
-
18
- ```ts
19
- import { allRenderers } from '@file-viewer/preset-all'
20
-
21
- const options = {
22
- builtinRenderers: 'none',
23
- renderers: allRenderers,
24
- }
25
- ```
26
-
27
- ## Capabilities
28
-
29
- - Reads GeoJSON `FeatureCollection`, `Feature`, and standalone geometry objects.
30
- - Loads `@tmcw/togeojson` only for KML / GPX and normalizes them into the shared GeoJSON pipeline.
31
- - Loads `shpjs` only for SHP / Shapefile previews, including common ZIP or binary Shapefile payloads.
32
- - Uses an offline MapLibre empty style to render point, line, and polygon overlays with pan, zoom, and fit-to-bounds controls. Public, intranet, or fully self-hosted basemap tiles can be enabled explicitly.
33
- - Supports GeoJSON `crs` metadata, explicit `options.geo.projection`, Web Mercator inference, and conversion from `EPSG:4326`, `EPSG:3857`, `EPSG:4490`, `GCJ02`, `BD09`, or proj4 strings to WGS84.
34
- - Falls back to an SVG vector preview when WebGL or MapLibre initialization is unavailable.
35
- - Cleans up DOM resources on unmount and remains compatible with core lifecycle, HTML export, and zoom orchestration.
36
-
37
- ## Projection Options
38
-
39
- ```ts
40
- const options = {
41
- renderers: [geoRenderer],
42
- geo: {
43
- projection: 'EPSG:3857',
44
- inferProjection: true,
45
- fitPadding: 48,
46
- },
47
- }
48
- ```
49
-
50
- Standard GeoJSON is read as WGS84 by default. If an export omits `crs` but contains Web Mercator coordinates, the renderer infers EPSG:3857 by default. For non-EPSG systems such as GCJ-02 or BD-09, pass `options.geo.projection` explicitly.
51
-
52
- ## Basemap and Tile Options
53
-
54
- The geo renderer does not access public networks by default. When a real basemap is needed, pass a public MapLibre style, a self-hosted style, or a simple raster XYZ/TMS tile template:
55
-
56
- ```ts
57
- const options = {
58
- renderers: [geoRenderer],
59
- geo: {
60
- // International open-source basemap, good for demos or light online usage.
61
- // Production systems should self-host or mirror it when needed.
62
- basemap: 'openfreemap-liberty',
63
- },
64
- }
65
- ```
66
-
67
- ```ts
68
- const options = {
69
- renderers: [geoRenderer],
70
- geo: {
71
- // Simple raster tile entry. It can point to public tiles, an intranet gateway,
72
- // object storage, or a local static tile directory.
73
- tileUrl: '/tiles/world/{z}/{x}/{y}.png',
74
- },
75
- }
76
- ```
77
-
78
- ```ts
79
- const options = {
80
- renderers: [geoRenderer],
81
- geo: {
82
- basemap: {
83
- type: 'vector-style',
84
- label: 'Intranet OpenMapTiles',
85
- styleUrl: '/maps/styles/liberty/style.json',
86
- },
87
- },
88
- }
89
- ```
90
-
91
- Tianditu requires a token registered for the deployment's domain. Each built-in preset combines its base and annotation layers:
92
-
93
- ```ts
94
- const options = {
95
- renderers: [geoRenderer],
96
- geo: {
97
- basemap: 'tianditu-vector', // or tianditu-imagery / tianditu-terrain
98
- tiandituToken: import.meta.env.VITE_TIANDITU_TOKEN,
99
- },
100
- }
101
- ```
102
-
103
- Use `basemap: { type: 'tianditu', token, mapStyle: 'imagery', labels: false }` to omit annotations. The viewer never bundles, stores, or proxies the token; a missing token safely falls back to the offline empty basemap.
104
-
105
- Built-in presets include `openfreemap-liberty`, `openfreemap-bright`, `openfreemap-positron`, `openfreemap-dark`, `openfreemap-fiord`, explicit opt-in `osm-raster`, and the caller-token-based `tianditu-vector`, `tianditu-imagery`, and `tianditu-terrain` presets. Use `osm-raster` only for demos or low-volume traffic; production deployments should follow the official OpenStreetMap tile policy, keep the URL replaceable, cache correctly, and show attribution. OpenFreeMap / OpenMapTiles can also be self-hosted or mirrored to an intranet or domestic CDN and connected through `styleUrl` or `tileUrl`.
106
-
107
- ## Migration Note
108
-
109
- `@file-viewer/core` no longer bundles the geo renderer and no longer installs `@tmcw/togeojson` or `shpjs` by default. Install this renderer explicitly, or use `@file-viewer/preset-all`, when GeoJSON / KML / GPX / SHP preview is required.
7
+ The package's own license is Apache-2.0. Included third-party notices apply to their respective components.
package/README.md CHANGED
@@ -1,107 +1,7 @@
1
1
  # @file-viewer/renderer-geo
2
2
 
3
- Flyfish File Viewer 的独立地理数据 renderer 包。它负责 GeoJSON、KML、GPX 和 Shapefile 的浏览器端预览,并让 `@tmcw/togeojson`、`shpjs`、`maplibre-gl`、`proj4` 只在命中地理数据格式时加载。
3
+ Runtime package version 3.2.0.
4
4
 
5
- ## 使用
5
+ Usage and API documentation: https://doc.file-viewer.app/guide/on-demand-renderers
6
6
 
7
- ```ts
8
- import { geoRenderer } from '@file-viewer/renderer-geo'
9
-
10
- const options = {
11
- builtinRenderers: 'none',
12
- renderers: [geoRenderer],
13
- }
14
- ```
15
-
16
- 也可以通过全量 preset 自动装配:
17
-
18
- ```ts
19
- import { allRenderers } from '@file-viewer/preset-all'
20
-
21
- const options = {
22
- builtinRenderers: 'none',
23
- renderers: allRenderers,
24
- }
25
- ```
26
-
27
- ## 能力
28
-
29
- - GeoJSON 直接读取 `FeatureCollection`、`Feature` 或单个 geometry。
30
- - KML / GPX 只在命中格式时按需加载 `@tmcw/togeojson`,转换为统一 GeoJSON 管线。
31
- - SHP / Shapefile 只在命中格式时按需加载 `shpjs`,支持常见 ZIP 或二进制 Shapefile 数据转 GeoJSON。
32
- - 默认使用离线 MapLibre 空底图渲染点、线、面叠加层,支持平移、缩放和适配范围;显式配置后可叠加公网、内网或离线自托管瓦片底图。
33
- - 支持 GeoJSON `crs` 元数据、`options.geo.projection` 显式坐标系、Web Mercator 自动推断,以及 `EPSG:4326`、`EPSG:3857`、`EPSG:4490`、`GCJ02`、`BD09` 和 proj4 字符串转换到 WGS84。
34
- - WebGL 或 MapLibre 初始化失败时自动回退 SVG 矢量预览,适合内网部署和附件快速审阅。
35
- - 卸载时清理 DOM 资源,和 core 的生命周期、导出 HTML、缩放能力保持一致。
36
-
37
- ## 坐标系选项
38
-
39
- ```ts
40
- const options = {
41
- renderers: [geoRenderer],
42
- geo: {
43
- projection: 'EPSG:3857',
44
- inferProjection: true,
45
- fitPadding: 48,
46
- },
47
- }
48
- ```
49
-
50
- 标准 GeoJSON 默认按 WGS84 读取。如果业务导出没有写 `crs`,但坐标是 Web Mercator,默认会自动推断;GCJ-02 / BD-09 这类非 EPSG 坐标建议通过 `options.geo.projection` 显式声明。
51
-
52
- ## 底图和瓦片选项
53
-
54
- Geo renderer 默认不访问公网。需要真实底图时,可以选择公开 MapLibre style、自托管 style,或简单 raster XYZ/TMS 瓦片模板:
55
-
56
- ```ts
57
- const options = {
58
- renderers: [geoRenderer],
59
- geo: {
60
- // 国际化开源底图,适合 demo 或轻量在线场景;生产建议按需自托管或镜像到内网/国内 CDN。
61
- basemap: 'openfreemap-liberty',
62
- },
63
- }
64
- ```
65
-
66
- ```ts
67
- const options = {
68
- renderers: [geoRenderer],
69
- geo: {
70
- // 最简单的 raster 瓦片入口,可指向公网、内网网关、对象存储或本地静态目录。
71
- tileUrl: '/tiles/world/{z}/{x}/{y}.png',
72
- },
73
- }
74
- ```
75
-
76
- ```ts
77
- const options = {
78
- renderers: [geoRenderer],
79
- geo: {
80
- basemap: {
81
- type: 'vector-style',
82
- label: 'Intranet OpenMapTiles',
83
- styleUrl: '/maps/styles/liberty/style.json',
84
- },
85
- },
86
- }
87
- ```
88
-
89
- 天地图需要使用在天地图控制台为部署域名申请的 token。内置 preset 会同时加载对应的底图和中文注记图层:
90
-
91
- ```ts
92
- const options = {
93
- renderers: [geoRenderer],
94
- geo: {
95
- basemap: 'tianditu-vector', // 也支持 tianditu-imagery / tianditu-terrain
96
- tiandituToken: import.meta.env.VITE_TIANDITU_TOKEN,
97
- },
98
- }
99
- ```
100
-
101
- 需要隐藏注记时可使用对象形式:`basemap: { type: 'tianditu', token, mapStyle: 'imagery', labels: false }`。组件不会内置、保存或代理 token;未提供 token 时会安全回退到离线空底图。
102
-
103
- 内置 preset 包含 `openfreemap-liberty`、`openfreemap-bright`、`openfreemap-positron`、`openfreemap-dark`、`openfreemap-fiord`、显式 opt-in 的 `osm-raster`,以及需要调用方 token 的 `tianditu-vector`、`tianditu-imagery`、`tianditu-terrain`。`osm-raster` 只建议用于 demo 或低频访问,生产环境请遵守 OpenStreetMap 官方 tile policy,配置可替换 URL、缓存和正确 attribution。中国大陆也可以把 OpenFreeMap / OpenMapTiles 栈自托管到内网或国内 CDN,再通过 `styleUrl` 或 `tileUrl` 接入。
104
-
105
- ## 迁移说明
106
-
107
- `@file-viewer/core` 已不再内置 geo renderer,也不会默认安装 `@tmcw/togeojson` 和 `shpjs`。需要 GeoJSON / KML / GPX / SHP 预览时,请显式安装本包,或直接使用 `@file-viewer/preset-all` 聚合能力。
7
+ The package's own license is Apache-2.0. Included third-party notices apply to their respective components.