@richpods/tiny-geojson-tool 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.
package/README.md CHANGED
@@ -56,6 +56,7 @@ Both components accept:
56
56
  | `pmtilesUrl` | `string` | **(required)** | URL to a PMTiles archive for the base map |
57
57
  | `center` | `[lng, lat]` | `[0, 20]` | Initial map center |
58
58
  | `zoom` | `number` | `2` | Initial zoom level |
59
+ | `bboxPadding` | `[top, right, bottom, left]` | `[0, 0, 0, 0]` | Extra padding used when fitting to GeoJSON bounds |
59
60
 
60
61
  `GeoJsonEditor` additionally accepts:
61
62
 
@@ -65,6 +66,12 @@ Both components accept:
65
66
  | `pointRadius` | `number` | `10` | Radius of point features in pixels |
66
67
  | `l10n` | `Partial<EditorLocale>` | English | Override UI strings for localization |
67
68
 
69
+ Initial map view priority on load:
70
+
71
+ 1. If `modelValue.bbox` is present, it is used directly.
72
+ 2. Otherwise, bounds are calculated from `modelValue.features`.
73
+ 3. If no bounds can be determined (empty map), `center` and `zoom` are used.
74
+
68
75
  ## Drawing Tools
69
76
 
70
77
  The editor toolbar provides six modes:
@@ -78,20 +85,6 @@ The editor toolbar provides six modes:
78
85
 
79
86
  Right-click or press Escape to cancel drawing.
80
87
 
81
- ## Bounding Box
82
-
83
- The GeoJSON `bbox` member ([RFC 7946 §5](https://datatracker.ietf.org/doc/html/rfc7946#section-5)) can be used to store and restore a map view. `GeoJsonEditor` exposes a `saveBbox` method via template ref, and both components respect an existing `bbox` on load.
84
-
85
- ```javascript
86
- // Save the current map view as bbox
87
- editorRef.value.saveBbox();
88
-
89
- // Or provide a custom bbox [west, south, east, north]
90
- editorRef.value.saveBbox([-74.1, 40.6, -73.8, 40.9]);
91
- ```
92
-
93
- When a `bbox` is present on the feature collection, both `GeoJsonEditor` and `GeoJsonViewer` will fit the map to that bounding box on load (instead of auto-fitting to features). Explicit `center`/`zoom` props still take priority over `bbox`.
94
-
95
88
  ## Style Properties
96
89
 
97
90
  Features support [simplestyle-spec 1.1.0](https://github.com/mapbox/simplestyle-spec) properties:
@@ -143,20 +136,6 @@ See `EditorLocale` for the full list of keys and `DEFAULT_LOCALE` for the Englis
143
136
 
144
137
  All styles use CSS custom properties prefixed with `--tge-`. Override them to customize the look.
145
138
 
146
- ## Utilities
147
-
148
- The library exports helper functions for working with GeoJSON data outside of the components.
149
-
150
- | Function | Description |
151
- |----------|-------------|
152
- | `computeBbox(fc)` | Compute a `BBox` (`[west, south, east, north]`) from a feature collection. Returns `undefined` if there are no features. |
153
-
154
- ```ts
155
- import { computeBbox } from "@richpods/tiny-geojson-tool";
156
-
157
- const bbox = computeBbox(geojson.value);
158
- ```
159
-
160
139
  ## Base Map
161
140
 
162
141
  The base map expects vector tiles served from a PMTiles archive. We recommend the [Shortbread](https://shortbread-tiles.org/) schema for your tiles. You must provide the `pmtilesUrl` prop pointing to your own tile source.
@@ -1,4 +1,4 @@
1
- import type { BBox, EditorFeatureCollection, EditorFeature, Position, ToolMode } from "../types";
1
+ import type { EditorFeatureCollection, EditorFeature, Position, ToolMode, BboxPadding } from "../types";
2
2
  type __VLS_Props = {
3
3
  modelValue: EditorFeatureCollection;
4
4
  activeTool: ToolMode;
@@ -6,22 +6,18 @@ type __VLS_Props = {
6
6
  pointRadius?: number;
7
7
  center?: Position;
8
8
  zoom?: number;
9
+ bboxPadding?: BboxPadding;
9
10
  };
10
- declare function saveBbox(bbox?: BBox): void;
11
- declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
12
- saveBbox: typeof saveBbox;
13
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
11
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
14
12
  "update:modelValue": (value: EditorFeatureCollection) => any;
15
13
  featureClick: (feature: EditorFeature | null) => any;
16
14
  featureDelete: (id: string) => any;
17
15
  toolDone: (featureId: string) => any;
18
- moveend: () => any;
19
16
  }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
20
17
  "onUpdate:modelValue"?: ((value: EditorFeatureCollection) => any) | undefined;
21
18
  onFeatureClick?: ((feature: EditorFeature | null) => any) | undefined;
22
19
  onFeatureDelete?: ((id: string) => any) | undefined;
23
20
  onToolDone?: ((featureId: string) => any) | undefined;
24
- onMoveend?: (() => any) | undefined;
25
21
  }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
26
22
  declare const _default: typeof __VLS_export;
27
23
  export default _default;
@@ -1,28 +1,24 @@
1
- import type { BBox, EditorFeatureCollection, Position } from "../types";
1
+ import type { EditorFeatureCollection, Position, BboxPadding } from "../types";
2
2
  import type { EditorLocale } from "../l10n";
3
3
  type __VLS_Props = {
4
4
  pmtilesUrl: string;
5
5
  pointRadius?: number;
6
6
  center?: Position;
7
7
  zoom?: number;
8
+ bboxPadding?: BboxPadding;
8
9
  l10n?: Partial<EditorLocale>;
9
10
  };
10
- declare function saveBbox(bbox?: BBox): void;
11
11
  type __VLS_ModelProps = {
12
12
  modelValue?: EditorFeatureCollection;
13
13
  };
14
14
  type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
15
- declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
16
- saveBbox: typeof saveBbox;
17
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
15
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
18
16
  "update:modelValue": (value: EditorFeatureCollection) => any;
19
- } & {
20
- moveend: () => any;
21
17
  }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
22
18
  "onUpdate:modelValue"?: ((value: EditorFeatureCollection) => any) | undefined;
23
- onMoveend?: (() => any) | undefined;
24
19
  }>, {
25
20
  pointRadius: number;
21
+ bboxPadding: BboxPadding;
26
22
  l10n: Partial<EditorLocale>;
27
23
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
24
  declare const _default: typeof __VLS_export;
@@ -1,12 +1,14 @@
1
- import type { EditorFeatureCollection, Position } from "../types";
1
+ import type { EditorFeatureCollection, Position, BboxPadding } from "../types";
2
2
  type __VLS_Props = {
3
3
  modelValue?: EditorFeatureCollection;
4
4
  pmtilesUrl: string;
5
5
  center?: Position;
6
6
  zoom?: number;
7
+ bboxPadding?: BboxPadding;
7
8
  };
8
9
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
9
10
  modelValue: EditorFeatureCollection;
11
+ bboxPadding: BboxPadding;
10
12
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
11
13
  declare const _default: typeof __VLS_export;
12
14
  export default _default;
@@ -1,7 +1,7 @@
1
1
  import type { ToolMode, Position } from "../types";
2
2
  export declare function useDrawing(): {
3
3
  activeTool: import("vue").Ref<ToolMode, ToolMode>;
4
- drawingCoords: import("vue").Ref<[number, number][], [number, number][] | Position[]>;
4
+ drawingCoords: import("vue").Ref<[number, number][], Position[] | [number, number][]>;
5
5
  selectedFeatureId: import("vue").Ref<string | null, string | null>;
6
6
  isDrawing: import("vue").ComputedRef<boolean>;
7
7
  setTool: (tool: ToolMode) => void;
package/dist/index.d.ts CHANGED
@@ -9,8 +9,7 @@ export { useMapStyle } from "./composables/useMapStyle";
9
9
  export { getFeatureLayers, getFeatureLayerIds, getQueryableLayerIds, getVerticesLayer, reconcileFeatureLayers, getDrawingLayers, } from "./utils/layers";
10
10
  export type { GeomType, FeatureSummary } from "./utils/layers";
11
11
  export { loadIcon, loadIconsForFeatures, getIconUrl, COMMON_ICONS } from "./utils/icons";
12
- export { computeBbox } from "./utils/mapView";
13
12
  export { DEFAULT_LOCALE } from "./l10n";
14
13
  export type { EditorLocale } from "./l10n";
15
14
  export { SOURCE_ID, LAYER_IDS, DEFAULTS, MARKER_SIZE_SCALE } from "./constants";
16
- export type { EditorFeatureCollection, EditorFeature, EditorPolygonFeature, EditorLineStringFeature, EditorPointFeature, EditorMarkerFeature, EditorProperties, BaseProperties, FillStyleProperties, StrokeStyleProperties, MarkerStyleProperties, PointStyleProperties, LabelProperties, BBox, Position, ToolMode, EditorProps, ViewerProps, } from "./types";
15
+ export type { EditorFeatureCollection, EditorFeature, EditorPolygonFeature, EditorLineStringFeature, EditorPointFeature, EditorMarkerFeature, EditorProperties, BaseProperties, FillStyleProperties, StrokeStyleProperties, MarkerStyleProperties, PointStyleProperties, LabelProperties, Position, GeoJsonBbox, BboxPadding, ToolMode, EditorProps, ViewerProps, } from "./types";