Skip to content

GeoLeaf-JS — API Reference

Package: @geoleaf/coreVersion: 2.0.0 License: MIT

Auto-generated HTML docs: Run npm run docs:api in packages/core to generate the TypeDoc API reference at packages/core/docs/api/. This produces per-module HTML pages for all 31 named exports including full method signatures, parameter types, and return types.


Table of contents

  1. ESM named exports (31)
  2. GeoLeafAPI — top-level API
  3. Core — map lifecycle
  4. POI — points of interest
  5. UI — interface controls
  6. Filters — filter system
  7. Route — routing
  8. Table — data table
  9. Legend — legend panel
  10. LayerManager — GeoJSON layers
  11. Baselayers — base tiles
  12. Helpers
  13. Validators
  14. Themes — theme system
  15. API sub-modules
  16. Log
  17. Errors — typed error classes
  18. CONSTANTS
  19. Utils
  20. Config
  21. Search — search engine
  22. Geocoding — address search
  23. Permalink — URL deep linking
  24. Notifications — toast notifications
  25. PWA — install prompt
  26. Lazy loading system
  27. Global namespace (window.GeoLeaf.*)

ESM named exports (31)

All symbols available via import { … } from "@geoleaf/core":

ts
// Facade modules
import { Core } from "@geoleaf/core"; // Map lifecycle
import { GeoLeafAPI } from "@geoleaf/core"; // Unified top-level API
import { UI } from "@geoleaf/core"; // UI controls
import { POI } from "@geoleaf/core"; // Points of interest
import { Route } from "@geoleaf/core"; // Routing
import { Table } from "@geoleaf/core"; // Data table
import { Legend } from "@geoleaf/core"; // Legend panel
import { LayerManager } from "@geoleaf/core"; // GeoJSON layer management
import { Filters } from "@geoleaf/core"; // Filter panels
import { Baselayers } from "@geoleaf/core"; // Base tile layers
import { Helpers } from "@geoleaf/core"; // Utility helpers
import { Validators } from "@geoleaf/core"; // Input validators
import { Themes } from "@geoleaf/core"; // Theme system
import { Search } from "@geoleaf/core"; // Full-text POI search
import { Permalink } from "@geoleaf/core"; // URL deep linking
import { Events } from "@geoleaf/core"; // DOM event bus
import { Notifications } from "@geoleaf/core"; // Toast notifications
import { PWA } from "@geoleaf/core"; // PWA install prompt
import { Geocoding } from "@geoleaf/core"; // Geocoding / address search

// API sub-modules
import { APIController } from "@geoleaf/core";
import { APIFactoryManager } from "@geoleaf/core";
import { APIInitializationManager } from "@geoleaf/core";
import { APIModuleManager } from "@geoleaf/core";
import { PluginRegistry } from "@geoleaf/core";
import { BootInfo } from "@geoleaf/core";
import { showBootInfo } from "@geoleaf/core";

// Utilities
import { Log } from "@geoleaf/core"; // Logging
import { Errors } from "@geoleaf/core"; // Typed error classes
import { CONSTANTS } from "@geoleaf/core"; // Constants
import { Utils } from "@geoleaf/core"; // Utility modules
import { Config } from "@geoleaf/core"; // Config access

export default GeoLeaf; // default export: window.GeoLeaf (CDN/global passthrough)

GeoJSON is not a named export. GeoJSON layers are managed internally via LayerManager and JSON profiles. There is no GeoLeaf.GeoJSON public API.


GeoLeafAPI — top-level API

The top-level GeoLeaf API. Available as GeoLeaf (CDN/global) or GeoLeafAPI (ESM).

Methods

MethodSignatureDescription
init(options: object) => Promise<void>Initialize GeoLeaf with a map container and options
loadConfig(input: string | object) => Promise<void>Load config from URL or inline object
setTheme(theme: string) => voidApply a visual theme
createMap(id: string, options?: object) => object | nullCreate a new managed map instance
getMap(id: string) => object | nullGet a map instance by container id
getAllMaps() => object[]Get all active map instances
removeMap(id: string) => booleanDestroy a managed map instance
getModule(name: string) => object | nullGet a registered module by name
hasModule(name: string) => booleanCheck if a module is registered
getNamespace(name: string) => object | nullGet a top-level GeoLeaf namespace by name
getHealth() => object | nullGet APIController health/metrics
getMetrics() => object | nullAlias for getHealth()

Properties

PropertyTypeDescription
versionstringCurrent GeoLeaf version (e.g. "2.0.0")
CONSTANTSobjectReference to GeoLeaf.CONSTANTS
BaseLayersobjectAlias for GeoLeaf.Baselayers (backward compatibility)

Core — map lifecycle

Generated signatures: packages/core/docs/api/variables/Core.html (run npm run docs:api in packages/core)

ts
import { Core } from "@geoleaf/core";
// or: GeoLeaf.Core (CDN/global)
MethodSignatureDescription
init(options?: object) => IMapAdapter | nullInitialise the MapLibre map
getMap() => IMapAdapter | nullReturn the current map adapter instance
setTheme(theme: string) => voidApply a theme to the map container
getTheme() => stringGet the current theme name

Init options:

ts
Core.init({
    mapId: "map", // DOM element id or HTMLElement
    center: [lat, lng], // Initial center [lat, lng]
    zoom: 12, // Initial zoom level
    theme: "light", // Theme name (default: "light")
    mapOptions: {}, // Additional MapLibre GL JS MapOptions (optional)
});

POI — points of interest

ts
import { POI } from "@geoleaf/core";
// or: GeoLeaf.POI (CDN/global) — requires _loadModule("poi") in lazy mode

POI provides marker management, clustering, popup, and sidepanel functionality. The POI module is lazy-loaded and must be activated before use:

js
await GeoLeaf._loadModule("poi");
GeoLeaf.POI.init(config);
MethodSignatureDescription
init(config: object) => voidInitialise le module POI avec la configuration
showPoiDetails(poi: object, customLayout?: object) => Promise<void>Ouvre le panneau latéral sur un POI (avec layout custom optionnel)
openSidePanel(poi: object, customLayout?: object) => voidAlias direct vers le panneau latéral POI

Sub-resources available after loading:

  • GeoLeaf.POI.Renderers.FieldRenderers — field rendering helpers
  • GeoLeaf.POI.Renderers.MediaRenderers — media (image/video) rendering helpers

UI — interface controls

ts
import { UI } from "@geoleaf/core";
// or: GeoLeaf.UI (CDN/global)

UI manages controls, panels, content builder, and notification system.


Filters — filter system

ts
import { Filters } from "@geoleaf/core";
// or: GeoLeaf.Filters (CDN/global)

Filters provides text filters, category filters, and geographic proximity filters.


Route — routing

ts
import { Route } from "@geoleaf/core";
// or: GeoLeaf.Route (CDN/global) — requires _loadModule("route")

Route is lazy-loaded. Load before using:

js
await GeoLeaf._loadModule("route");
GeoLeaf.Route.init(config);
MethodSignatureDescription
init(options?: object) => voidInitialise le module avec la configuration routes
loadGPX(url: string) => Promise<void>Charge et affiche un tracé GPX depuis une URL
loadGeoJSON(geojson: object) => voidCharge un objet GeoJSON directement
loadFromConfig(routes: RouteConfig[]) => Promise<void>Charge plusieurs routes depuis une configuration
show() => voidAffiche la couche route
hide() => voidMasque la couche route
toggleVisibility() => voidBascule la visibilité de la couche route
clear() => voidSupprime tous les tracés chargés
addWaypoint(latlng: [number, number]) => voidAjoute un point de passage
addSegment(coords: [number, number][]) => voidAjoute un segment de tracé
filterVisibility(routes: string[]) => voidFiltre la visibilité par IDs de routes
isInitialized() => booleanRetourne true si le module est initialisé
isVisible() => booleanRetourne true si la couche est visible

Table — data table

ts
import { Table } from "@geoleaf/core";
// or: GeoLeaf.Table (CDN/global) — requires _loadModule("table")

Table is lazy-loaded:

js
await GeoLeaf._loadModule("table");
GeoLeaf.Table.init(config);

Not included in the Lite bundle (bundle-core-lite-entry.ts).

MethodSignatureDescription
init(options: { map: any, config?: object }) => voidInitialise le module table avec une instance de carte
show() => voidAffiche le panneau table
hide() => voidMasque le panneau table
toggle() => voidBascule la visibilité du panneau
setLayer(layerId: string | null) => voidSélectionne une couche GeoJSON à afficher
refresh() => voidRecharge les données de la couche courante
sortByField(field: string) => voidTrie le tableau par un champ donné
setSelection(ids: any[], add?: boolean) => voidSélectionne des entités par ID (fusion si add=true)
getSelectedIds() => string[]Retourne les IDs des entités sélectionnées
clearSelection() => voidDésélectionne toutes les entités
zoomToSelection() => voidZoome sur l'emprise des entités sélectionnées
highlightSelection(active: boolean) => voidActive/désactive la surbrillance sur la carte
exportSelection() => voidTélécharge les entités sélectionnées en CSV

Configuration (tableConfig dans ui.json) :

json
{
    "tableConfig": {
        "enabled": true,
        "defaultVisible": false,
        "pageSize": 50,
        "maxRowsPerLayer": 1000,
        "enableExportButton": true,
        "virtualScrolling": true,
        "defaultHeight": "40%",
        "minHeight": "20%",
        "maxHeight": "60%",
        "resizable": true
    }
}

Legend — legend panel

ts
import { Legend } from "@geoleaf/core";
// or: GeoLeaf.Legend (CDN/global) — requires _loadModule("legend")

Legend is lazy-loaded.

Note: GeoLeaf.Legend and GeoLeaf.LayerManager are independent modules with separate implementations. Legend manages visual legend panels generated from layer style data. LayerManager manages GeoJSON layer loading and visibility controls.

MethodSignatureDescription
init(mapInstance: any, options?: object) => booleanInitialise le module avec une instance de carte
loadLayerLegend(layerId: string, styleId: string, layerConfig: object) => voidCharge et affiche la légende d'une couche
setLayerVisibility(layerId: string, visible: boolean) => voidMasque / affiche une couche depuis la légende
getAllLayers() => Map<string, object>Retourne l'ensemble des couches connues de la légende
hideLegend() => voidMasque le panneau légende
removeLegend() => voidSupprime le panneau légende du DOM
isLegendVisible() => booleanRetourne la visibilité courante du panneau
toggleAccordion(layerId: string) => voidOuvre / ferme l'accordéon d'une couche dans la légende

LayerManager — GeoJSON layers

ts
import { LayerManager } from "@geoleaf/core";
// or: GeoLeaf.LayerManager (CDN/global) — requires _loadModule("layerManager")

LayerManager manages GeoJSON layers loaded from profiles. It is the primary way to work with GeoJSON data in GeoLeaf.

Note: GeoLeaf.GeoJSON does not exist as a public API. Data access is exclusively through LayerManager and JSON profiles.


Baselayers — base tiles

ts
import { Baselayers } from "@geoleaf/core";
// or: GeoLeaf.Baselayers (CDN/global)

Baselayers manages raster tile layers and vector tile layers (via MapLibre GL).


Helpers

ts
import { Helpers } from "@geoleaf/core";
// or: GeoLeaf.Helpers (CDN/global)

Validators

ts
import { Validators } from "@geoleaf/core";
// or: GeoLeaf.Validators (CDN/global)

Themes — theme system

ts
import { Themes } from "@geoleaf/core"; // direct named export — lazy-loaded at runtime
// or: GeoLeaf.Themes (CDN/global) — requires _loadModule("themes")

API sub-modules

ts
import {
    APIController,
    APIFactoryManager,
    APIInitializationManager,
    APIModuleManager,
    PluginRegistry,
    BootInfo,
    showBootInfo,
} from "@geoleaf/core";

PluginRegistry

ts
GeoLeaf.PluginRegistry.isLoaded("storage"); // → boolean
GeoLeaf.PluginRegistry.getLoadedPlugins(); // → string[]
GeoLeaf.PluginRegistry.canActivate("addpoi"); // → boolean
GeoLeaf.PluginRegistry.register("name", metadata); // called by plugins
GeoLeaf.PluginRegistry.registerLazy("name", fn); // called by bundle-entry

showBootInfo / BootInfo

ts
import { showBootInfo } from "@geoleaf/core";
showBootInfo(); // prints boot diagnostics to console

Log

ts
import { Log } from "@geoleaf/core";
// or: GeoLeaf.Log (CDN/global)

Log.info("message");
Log.warn("message");
Log.error("message", error);

Errors — typed error classes

ts
import { Errors } from "@geoleaf/core";
// or: GeoLeaf.Errors (CDN/global)

9 typed error classes (see errors/GeoLeaf_Errors_README.md).


CONSTANTS

ts
import { CONSTANTS } from "@geoleaf/core";
// or: GeoLeaf.CONSTANTS (CDN/global)

CONSTANTS.VERSION; // Current version string
CONSTANTS.DEFAULT_CENTER; // Default map center
CONSTANTS.DEFAULT_ZOOM; // Default zoom level
// … see constants/GeoLeaf_Constants_README.md for full list

Utils

ts
import { Utils } from "@geoleaf/core";
// or: GeoLeaf.Utils (CDN/global)

13 utility sub-modules registered on GeoLeaf.Utils:

Sub-moduleDescription
AnimationHelperCSS animation utilities
DOMSecuritySafe DOM manipulation
ErrorLoggerError logging utilities
EventHelpersDOM event helpers
EventListenerManagerManaged event listeners
EventBusPub/sub event bus
FetchHelperFetch with cache/timeout
FileValidatorFile type & size validation
MapHelpersMapLibre GL JS map utilities
PerformanceProfilerTiming/perf profiling
LazyLoaderModule lazy loader utilities
TimerManagerManaged timers/debounce
ObjectUtils / ScaleUtilsObject & scale helpers

Config

ts
import { Config } from "@geoleaf/core";
// or: GeoLeaf.Config (CDN/global)

Config.get("map"); // Get a config section
Config.get("ui"); // Get UI config
Config.set("key", value); // Set a config value

Search — search engine

ts
import { Search } from "@geoleaf/core";
// or: GeoLeaf.Search (CDN/global) — requires _loadModule("search")

Full-text POI search backed by FlexSearch (with native includes() fallback when FlexSearch is unavailable).

MethodSignatureDescription
isReady() => booleanReturns true when the FlexSearch index is built
query(text: string) => Set<string>Returns a Set of matching POI IDs
build(pois: any[]) => void(Re)build the index from a POI array
getEngine() => "flexsearch" | "native"Returns the active engine name
clear() => voidClears the index (e.g. on profile switch)
ts
if (GeoLeaf.Search.isReady()) {
    const ids = GeoLeaf.Search.query("randonnée");
}

Auto-build: The index is built automatically on geoleaf:poi:loaded. build() is only needed for manual reloads.


ts
import { Geocoding } from "@geoleaf/core";
// or: GeoLeaf.Geocoding (CDN/global)

Controle de recherche d'adresse intégré à la carte. Supporte 4 providers (BAN/Addok, Nominatim, Photon, custom HTTPS). Activé via geocodingConfig.enabled: true dans le profil.

MéthodeSignatureDescription
isEnabled() => booleanRetourne true si le module geocoding est actif
search(query: string, limit?: number) => Promise<GeocodingResult[]>Recherche d'adresse et retourne les résultats
selectResult(result: GeocodingResult) => voidSélectionne un résultat (zoom + émission de l'événement)
destroy() => voidSupprime le contrôle de la carte et nettoie les listeners

Type GeocodingResult :

ts
interface GeocodingResult {
    label: string; // Adresse formattée
    lat: number; // Latitude WGS 84
    lng: number; // Longitude WGS 84
    bounds?: { north: number; south: number; east: number; west: number }; // Emprise optionnelle
    raw?: unknown; // Réponse brute du provider
}

Exemple :

ts
if (GeoLeaf.Geocoding.isEnabled()) {
    const results = await GeoLeaf.Geocoding.search("Paris", 5);
    if (results.length > 0) {
        GeoLeaf.Geocoding.selectResult(results[0]); // zoom vers le premier résultat
    }
}

Configuration (dans geocodingConfig du profil) :

json
{
    "geocodingConfig": {
        "enabled": true,
        "provider": "addok",
        "position": "top-right",
        "placeholder": "Rechercher une adresse…",
        "minChars": 3,
        "resultLimit": 5,
        "debounceMs": 300,
        "flyToZoom": 15
    }
}

Providers disponibles : "addok" (BAN France, défaut), "nominatim" (OSM, mondial), "photon" (Komoot, mondial), ou une URL HTTPS custom.

Événement émis : geoleaf:geocoding:result avec payload { label, lat, lng, bounds } lors de la sélection d’un résultat.

ts
import { Permalink } from "@geoleaf/core";
// or: GeoLeaf.Permalink (CDN/global)

Synchronises map state (center, zoom, active layers, filters) to the URL hash or query string. Enable in config: { "ui": { "permalink": { "enabled": true, "mode": "hash" } } }.

MethodSignatureDescription
init(config: PermalinkConfig) => voidInitialise with the ui.permalink config block
readAndStore() => voidParse current URL and cache the state
applyStoredState(map: any) => voidRestore the cached state to a map instance
startSync(map: any) => voidBegin continuous URL synchronisation on map move/zoom
getState() => PermalinkState | nullReturn the last cached state (read-only)
buildUrl(state?: PermalinkState | null) => stringSerialise a state to a URL fragment/query string
ts
// Typical lifecycle (handled automatically by the boot sequence):
Permalink.init(config.ui.permalink);
Permalink.readAndStore(); // before map creation
Permalink.applyStoredState(map); // after map + modules are ready
Permalink.startSync(map); // begin sync

Security: lat, lng, zoom are validated via validateNumber() / validateCoordinates(). Layer IDs are string-filtered (max 100 entries). Filter text is truncated to 200 chars.


Notifications — toast notifications

ts
import { Notifications } from "@geoleaf/core";
// or: GeoLeaf.Notifications (CDN/global) — or shortcut: GeoLeaf.notify(msg, type)

Displays non-blocking toast messages. Queued automatically when the DOM is not yet ready.

MethodSignatureDescription
notify(msg, type?, duration?) => voidDisplay a toast (generic)
success(msg, opts?) => voidGreen success toast
error(msg, opts?) => voidRed error toast (5 s default, persistent option)
warning(msg, opts?) => voidYellow warning toast
info(msg, opts?) => voidBlue informational toast
dismiss(toastEl: HTMLElement) => voidDismiss a specific toast
clearAll() => voidRemove all toasts and clear the queue
getStatus() => NotifyStatusReturn current system state (activeToasts, queued)
ts
Notifications.success("Données chargées");
Notifications.error("Échec du chargement", { persistent: true, dismissible: true });
Notifications.notify("Info", "info", { duration: 8000 });

PWA — install prompt

ts
import { PWA } from "@geoleaf/core";
// or: GeoLeaf.PWA (CDN/global)

Manages the Progressive Web App install banner (iOS) and install prompt (Chrome/Android). Activated automatically by the boot sequence when pwa.installPrompt.enabled: true in config.

MethodSignatureDescription
init(config: PWAConfig) => voidInitialise PWA features (called by boot — opt-in only)
ts
// Opt-in via geoleaf.config.json:
// { "pwa": { "installPrompt": { "enabled": true } } }

// Manual check (advanced):
GeoLeaf.PWA.init({ installPrompt: { enabled: true } });

Note: PWA features are opt-in. Without installPrompt.enabled: true, init() is a no-op.


Lazy loading system

See ARCHITECTURE_GUIDE.md for detailed documentation on _loadModule() and _loadAllSecondaryModules().

js
// Load a single module
await GeoLeaf._loadModule("poi");

// Load all secondary modules
await GeoLeaf._loadAllSecondaryModules();

Available module names: "poi", "poiCore", "poiRenderers", "poiExtras", "basemapSelector", "route", "layerManager", "legend", "labels", "themes", "table", "search".

Note — Lite build: bundle-core-lite-entry does not support "route", "labels", "table", or "search" — these are excluded from the lite bundle.


Global namespace (window.GeoLeaf.*)

After loading dist/geoleaf.esm.js via CDN (<script type="module">), the following properties are available on window.GeoLeaf (populated during boot B1→B11):

PropertyAvailable sinceDescription
GeoLeaf.CoreBoot B11Map lifecycle
GeoLeaf.POIBoot B11 (lazy)Points of interest
GeoLeaf.UIBoot B11UI controls
GeoLeaf.FiltersBoot B11Filters
GeoLeaf.RouteBoot B11 (lazy)Routing
GeoLeaf.TableBoot B11 (lazy)Data table
GeoLeaf.LegendBoot B11 (lazy)Legend panel
GeoLeaf.LayerManagerBoot B11 (lazy)Layer management
GeoLeaf.BaselayersBoot B11Base tile layers
GeoLeaf.HelpersBoot B11Helpers
GeoLeaf.ValidatorsBoot B11Validators
GeoLeaf.ThemesBoot B11 (lazy)Theme system
GeoLeaf.LabelsBoot B11 (lazy)Labels
GeoLeaf.UtilsBoot B2Utilities
GeoLeaf.CONSTANTSBoot B1Constants
GeoLeaf.LogBoot B1Logging
GeoLeaf.ErrorsBoot B1Error classes
GeoLeaf.SecurityBoot B1XSS/CSRF protection
GeoLeaf.ConfigBoot B4Config access
GeoLeaf.SearchBoot B11 (lazy)Full-text POI search
GeoLeaf.GeocodingBoot B11Recherche d'adresse
GeoLeaf.PermalinkBoot B4URL deep linking
GeoLeaf.NotificationsBoot B4Toast notifications
GeoLeaf.PWABoot B4PWA install prompt
GeoLeaf.StorageRuntime (plugin)Storage plugin namespace
GeoLeaf.PluginRegistryBoot B11Plugin registry
GeoLeaf._loadModuleBoot ESMLazy load a module
GeoLeaf._loadAllSecondaryModulesBoot ESMLoad all lazy modules
GeoLeaf._versionBoot B1Version string

TypeDoc (generated): Run npm run docs:api in packages/core to generate complete API documentation from TSDoc comments into docs/api/.


TypeScript types

@geoleaf/core ships TypeScript declarations. The canonical types entry point is:

ts
// tsconfig.json path (built declarations)
"types": ["@geoleaf/core"]
// Resolves to: node_modules/@geoleaf/core/dist/types/bundle-esm-entry.d.ts

Key types exported from the package:

ts
import type {
    GeoLeafBootOptions,
    GeoLeafConfig,
    GeoLeafProfile,
    GeoLeafEventMap,
    GeocodingConfig,
    GeocodingResult,
    PoiLike,
    LayerConfig,
    ThemeConfig,
} from "@geoleaf/core";

All public façades (GeoLeaf.*) are typed as the matching *Api interface found in packages/core/src/contracts/. See packages/core/index.d.ts at the package root for the legacy re-export shim, or use the full declarations in dist/types/.

Released under the MIT License.