Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/geolibre-desktop/src/hooks/usePlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,9 @@ export function createAppAPI(mapControllerRef?: RefObject<MapController | null>)
return state === undefined ? true : manager.applyPluginState(pluginId, api, state);
},
queryOvertureFeatures,
addLayerGroup: (name?: string, layerIds?: string[]) =>
useAppStore.getState().addLayerGroup(name, layerIds),
removeLayerGroup: (id: string) => useAppStore.getState().removeLayerGroup(id),
fitBounds: (bounds: [number, number, number, number]) =>
mapControllerRef?.current?.fitBounds(bounds),
getMap: () => mapControllerRef?.current?.getMap() ?? null,
Expand Down
1 change: 1 addition & 0 deletions apps/geolibre-desktop/src/lib/external-native-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,6 @@ export function createExternalNativeStoreLayer(
beforeId: registration.beforeId ?? existing?.beforeId,
geojson: registration.geojson ?? existing?.geojson,
sourcePath: registration.sourcePath ?? existing?.sourcePath,
groupId: registration.groupId ?? existing?.groupId,
};
}
9 changes: 9 additions & 0 deletions packages/plugins/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export type GeoLibreBuiltInMapControl =
export interface GeoLibreExternalNativeLayerRegistration {
id: string;
name: string;
/** Optional host layer-group id that should contain this layer. */
groupId?: string;
type?: GeoLibreLayer["type"];
source?: Record<string, unknown>;
geojson?: FeatureCollection;
Expand Down Expand Up @@ -427,6 +429,13 @@ export interface GeoLibreAppAPI {
* PMTiles integration. The host enforces tile and feature limits.
*/
queryOvertureFeatures?: (query: GeoLibreOvertureQuery) => Promise<GeoLibreOvertureQueryResult>;
/**
* Create a named Layers-panel group, optionally assigning existing layer ids
* to it, and return the new group id.
*/
addLayerGroup?: (name?: string, layerIds?: string[]) => string;
/** Remove a Layers-panel group without removing its child layers. */
removeLayerGroup?: (id: string) => void;
fitBounds?: (bounds: [number, number, number, number]) => void;
getMap?: () => MapLibreMap | null;
/**
Expand Down
11 changes: 11 additions & 0 deletions tests/external-native-layer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,15 @@ describe("createExternalNativeStoreLayer", () => {

assert.equal(layer.visible, false);
});

it("assigns and preserves the requested host layer group", () => {
const grouped = createExternalNativeStoreLayer(baseRegistration({ groupId: "event-imagery" }));
assert.equal(grouped.groupId, "event-imagery");

const updated = createExternalNativeStoreLayer(
baseRegistration({ name: "Updated Plugin Layer" }),
grouped,
);
assert.equal(updated.groupId, "event-imagery");
});
});
Loading