@richpods/tiny-geojson-tool 0.1.0 → 0.1.1
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 +28 -0
- package/dist/components/EditorMap.vue.d.ts +7 -2
- package/dist/components/GeoJsonEditor.vue.d.ts +8 -2
- package/dist/index.d.ts +2 -1
- package/dist/tiny-geojson-tool.js +864 -821
- package/dist/types.d.ts +2 -0
- package/dist/utils/mapView.d.ts +6 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,6 +78,20 @@ The editor toolbar provides six modes:
|
|
|
78
78
|
|
|
79
79
|
Right-click or press Escape to cancel drawing.
|
|
80
80
|
|
|
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
|
+
|
|
81
95
|
## Style Properties
|
|
82
96
|
|
|
83
97
|
Features support [simplestyle-spec 1.1.0](https://github.com/mapbox/simplestyle-spec) properties:
|
|
@@ -129,6 +143,20 @@ See `EditorLocale` for the full list of keys and `DEFAULT_LOCALE` for the Englis
|
|
|
129
143
|
|
|
130
144
|
All styles use CSS custom properties prefixed with `--tge-`. Override them to customize the look.
|
|
131
145
|
|
|
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
|
+
|
|
132
160
|
## Base Map
|
|
133
161
|
|
|
134
162
|
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 { EditorFeatureCollection, EditorFeature, Position, ToolMode } from "../types";
|
|
1
|
+
import type { BBox, EditorFeatureCollection, EditorFeature, Position, ToolMode } from "../types";
|
|
2
2
|
type __VLS_Props = {
|
|
3
3
|
modelValue: EditorFeatureCollection;
|
|
4
4
|
activeTool: ToolMode;
|
|
@@ -7,16 +7,21 @@ type __VLS_Props = {
|
|
|
7
7
|
center?: Position;
|
|
8
8
|
zoom?: number;
|
|
9
9
|
};
|
|
10
|
-
declare
|
|
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
14
|
"update:modelValue": (value: EditorFeatureCollection) => any;
|
|
12
15
|
featureClick: (feature: EditorFeature | null) => any;
|
|
13
16
|
featureDelete: (id: string) => any;
|
|
14
17
|
toolDone: (featureId: string) => any;
|
|
18
|
+
moveend: () => any;
|
|
15
19
|
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
16
20
|
"onUpdate:modelValue"?: ((value: EditorFeatureCollection) => any) | undefined;
|
|
17
21
|
onFeatureClick?: ((feature: EditorFeature | null) => any) | undefined;
|
|
18
22
|
onFeatureDelete?: ((id: string) => any) | undefined;
|
|
19
23
|
onToolDone?: ((featureId: string) => any) | undefined;
|
|
24
|
+
onMoveend?: (() => any) | undefined;
|
|
20
25
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
21
26
|
declare const _default: typeof __VLS_export;
|
|
22
27
|
export default _default;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EditorFeatureCollection, Position } from "../types";
|
|
1
|
+
import type { BBox, EditorFeatureCollection, Position } from "../types";
|
|
2
2
|
import type { EditorLocale } from "../l10n";
|
|
3
3
|
type __VLS_Props = {
|
|
4
4
|
pmtilesUrl: string;
|
|
@@ -7,14 +7,20 @@ type __VLS_Props = {
|
|
|
7
7
|
zoom?: number;
|
|
8
8
|
l10n?: Partial<EditorLocale>;
|
|
9
9
|
};
|
|
10
|
+
declare function saveBbox(bbox?: BBox): void;
|
|
10
11
|
type __VLS_ModelProps = {
|
|
11
12
|
modelValue?: EditorFeatureCollection;
|
|
12
13
|
};
|
|
13
14
|
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
14
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
15
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
16
|
+
saveBbox: typeof saveBbox;
|
|
17
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
15
18
|
"update:modelValue": (value: EditorFeatureCollection) => any;
|
|
19
|
+
} & {
|
|
20
|
+
moveend: () => any;
|
|
16
21
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
17
22
|
"onUpdate:modelValue"?: ((value: EditorFeatureCollection) => any) | undefined;
|
|
23
|
+
onMoveend?: (() => any) | undefined;
|
|
18
24
|
}>, {
|
|
19
25
|
pointRadius: number;
|
|
20
26
|
l10n: Partial<EditorLocale>;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ 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";
|
|
12
13
|
export { DEFAULT_LOCALE } from "./l10n";
|
|
13
14
|
export type { EditorLocale } from "./l10n";
|
|
14
15
|
export { SOURCE_ID, LAYER_IDS, DEFAULTS, MARKER_SIZE_SCALE } from "./constants";
|
|
15
|
-
export type { EditorFeatureCollection, EditorFeature, EditorPolygonFeature, EditorLineStringFeature, EditorPointFeature, EditorMarkerFeature, EditorProperties, BaseProperties, FillStyleProperties, StrokeStyleProperties, MarkerStyleProperties, PointStyleProperties, LabelProperties, Position, ToolMode, EditorProps, ViewerProps, } from "./types";
|
|
16
|
+
export type { EditorFeatureCollection, EditorFeature, EditorPolygonFeature, EditorLineStringFeature, EditorPointFeature, EditorMarkerFeature, EditorProperties, BaseProperties, FillStyleProperties, StrokeStyleProperties, MarkerStyleProperties, PointStyleProperties, LabelProperties, BBox, Position, ToolMode, EditorProps, ViewerProps, } from "./types";
|