diff --git a/packages/legend/README.md b/packages/legend/README.md index a35ec0c..16d2410 100644 --- a/packages/legend/README.md +++ b/packages/legend/README.md @@ -26,17 +26,10 @@ createLegendFromLayer(layer).then((legendDiv) => { }); ``` -## API Documentation +## Documentation -### `createLegendFromLayer(layer: Layer): Promise` +For more detailed API documentation, see the [documentation website](https://camptocamp.github.io/geospatial-sdk/docs/). -Creates a legend from a layer. +## Examples -#### Parameters - -- `layer: (MapContextLayer)`: The layer to create the legend from. -- `options: (LegendOptions, optional)`: The options to create the legend. - -#### Returns - -- `Promise`: A promise that resolves to the legend element or `false` if the legend could not be created. +For examples and demos, see the [examples website](https://camptocamp.github.io/geospatial-sdk/). diff --git a/packages/legend/lib/create-legend/from-layer.ts b/packages/legend/lib/create-legend/from-layer.ts index 279761a..5d142d8 100644 --- a/packages/legend/lib/create-legend/from-layer.ts +++ b/packages/legend/lib/create-legend/from-layer.ts @@ -82,24 +82,23 @@ async function createWmtsLegendUrl( } /** - * Create a legend from a layer + * Creates a legend from a layer. * - * - * @param layer - The MapContextLayer to create a legend from - * @param options - Optional configuration for legend generation - * @returns The legend as a DOM element or false if the legend could not be created + * @param {MapContextLayer} layer - The layer to create the legend from. + * @param {LegendOptions} [options] - The options to create the legend. + * @returns {Promise} A promise that resolves to the legend element or `null` if the legend could not be created. */ export async function createLegendFromLayer( layer: MapContextLayer, options: LegendOptions = {}, -): Promise { +): Promise { if ( (layer.type !== "wms" && layer.type !== "wmts") || !layer.url || !layer.name ) { console.error("Invalid layer for legend creation"); - return false; + return null; } // Create a container for the legend