TomTom Maps for JavaScript
    Preparing search index...

    Type Alias CustomGeoJSONModuleConfig<TSources>

    CustomGeoJSONModuleConfig: MapModuleCommonConfig & {
        images?: Record<string, CustomGeoJSONImageSpec>;
        sources: { [K in keyof TSources]: CustomGeoJSONSourceSpec };
        visible?: boolean;
    }

    Configuration for the CustomGeoJSONModule.

    Type Parameters

    Type Declaration

    • Optionalimages?: Record<string, CustomGeoJSONImageSpec>

      Custom images to register on the map by ID. The module adds each image during setup, before any source or layer is created, and re-adds every image after every style change — so symbol layers referencing an image via icon-image: '<id>' survive setStyle calls automatically.

      • Existing images on the map are not overwritten — the module skips IDs for which map.hasImage(id) is already true.
      • Only synchronous MapLibre image payloads are supported. URLs and raw SVG strings must be loaded by the caller before being passed in.
      • applyConfig re-runs image registration additively: new IDs are added, already-present IDs are skipped, and removing an entry from images does not unregister it from the map (other layers may still reference it).
      const config: CustomGeoJSONModuleConfig = {
      sources: {
      markers: { layers: [{ type: 'symbol', layout: { 'icon-image': 'my-marker' } }] },
      },
      images: {
      'my-marker': { image: myImageBitmap, options: { pixelRatio: 2 } },
      },
      };
    • sources: { [K in keyof TSources]: CustomGeoJSONSourceSpec }

      The sources, keyed by an arbitrary user-defined name, that this module manages.

      The set of source names is fixed at module creation time. Calling applyConfig with new source names or omitting existing ones is not supported — only the layer specs and visibility of existing sources can be updated at runtime.

    • Optionalvisible?: boolean

      Initial visibility for all layers across all sources. Defaults to true.

      After show(name, data) is called for a source, layer visibility follows the data state (visible iff the feature collection is non-empty). Use CustomGeoJSONModule.setVisible to override that automatic behaviour at runtime.

    type MySources = {
    buildings: FeatureCollection<Point, { name: string }>;
    parks: FeatureCollection<Polygon>;
    };

    const config: CustomGeoJSONModuleConfig<MySources> = {
    sources: {
    buildings: { layers: [{ type: 'circle', paint: { 'circle-radius': 4 } }] },
    parks: { layers: [{ type: 'fill', paint: { 'fill-color': '#5a5' } }] },
    },
    };