TomTom Maps for JavaScript
    Preparing search index...

    Class CustomLayer<HIT>

    A MapLibre custom layer the SDK places in the layer stack and keeps there through style changes, returned by TomTomMap.addCustomLayer.

    With a hitTest, the objects the layer draws take user events as a module's features do. Its events fire on them, they win over what lies under them, and they get the hover cursor and event states.

    const vehicles = map.addCustomLayer(vehiclesLayer, {
    beforeLayerConfig: 'lowest3D',
    hitTest: (point) => pickVehicles(point), // [{ id, properties }], topmost first
    });
    vehicles.events.on('click', (vehicle) => inspector.show(vehicle));

    vehicles.remove();

    Type Parameters

    Index
    events: UserEvents<HIT>

    The user events of the objects the layer draws, which fire only with a hitTest.

    Handlers receive the objects the hit tester returned, the topmost first. A where() predicate takes them too.

    id: string

    The layer's id, as MapLibre knows it.

    • Takes the layer off the map, stops placing it after style changes, and drops its event handlers.

      Returns void