This is the documentation of version 1.0.0-rc.0. Go to the latest version, 1.0.0-rc.5.
TomTom Maps for JavaScript
    Preparing search index...

    Type Alias CustomGeoJSONModuleConfig<TSources>

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

    Configuration for the CustomGeoJSONModule.

    Type Parameters

    Type Declaration

    • OptionalbeforeLayerConfig?: CustomGeoJSONBeforeLayerConfig

      Where the layers that set no beforeLayerConfig of their own go in the map's layer stack.

      Within a source, the layers array order decides the draw order of layers sharing a target.

      'top'
      
    • 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. Symbol layers that reference an image with icon-image: '<id>' therefore survive setStyle calls automatically.

      • Existing images on the map aren't overwritten. The module skips IDs for which map.hasImage(id) is already true.
      • Only synchronous MapLibre image payloads are supported. You must load URLs and raw SVG strings before passing them in.
      • applyConfig re-runs image registration additively. It adds new IDs and skips present ones. Removing an entry from images doesn't unregister it from the map, since 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. At runtime, you can update only the layer specs and visibility of existing sources.

    • Optionalvisible?: boolean

      Whether the module draws every layer of every source.

      A shown source draws its layers while it holds features. show() and clear() never change this. A hidden module keeps its data until CustomGeoJSONModule.setVisible shows it again.

      true
      
    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' } }] },
    },
    };

    CustomGeoJSONModuleSerializableConfig for the part that survives JSON.