NextGIS Frontend
    Preparing search index...

    Interface VectorLayerAdapter<M, L, O, F, PROP, P>

    Adapter for vector data display control.

    interface VectorLayerAdapter<
        M = any,
        L = any,
        O extends VectorAdapterOptions = VectorAdapterOptions,
        F extends Feature = Feature,
        PROP extends
            Record<string, any> | null = F extends Feature
            ? F["properties"]
            : Record<string, string>,
        P extends
            Record<string, any> = PROP extends null ? Record<string, any> : PROP,
    > {
        id?: string;
        layer?: L;
        map?: M;
        name?: string;
        options: O;
        order?: number;
        selected?: boolean;
        source?: unknown;
        addData?(geojson: GeoJsonObject): void | Promise<void>;
        addLayer(options: O): L | Promise<L> | undefined;
        beforeRemove?(): void;
        clearLayer?(cb?: (feature: F) => boolean): void | Promise<void>;
        closePopup?(findFeatureCb?: DataLayerFilter<F, L>): void;
        filter?(
            cb: DataLayerFilter<F, L>,
        ): LayerDefinition<Feature<Geometry, GeoJsonProperties>, L>[];
        getBounds?(): | LngLatBoundsArray
        | Promise<(LngLatBoundsArray | undefined)>
        | undefined;
        getDependLayers?(): L[];
        getExtent?(): | LngLatBoundsArray
        | Promise<(LngLatBoundsArray | undefined)>
        | undefined;
        getFiltered?(): LayerDefinition<Feature<Geometry, GeoJsonProperties>, L>[];
        getLayers?(): LayerDefinition<F, L>[];
        getLegend?(options?: GetLegendOptions): Promise<LayerLegend[]>;
        getSelected?(): LayerDefinition<Feature<Geometry, GeoJsonProperties>, L>[];
        hideLabel?(): void;
        hideLayer?(layer?: L): void;
        isLabelVisible?(): boolean;
        onLayerClick?(event: OnLayerMouseOptions): Promise<any>;
        openPopup?(
            findFeatureCb?: DataLayerFilter<F, L>,
            options?: PopupOptions<Feature<Geometry, GeoJsonProperties>, any>,
        ): void;
        propertiesFilter?(
            filters: PropertiesFilter<P>,
            options?: FilterOptions<P>,
        ): Promise<void>;
        removeFilter?(): void;
        removeLayer?(): void;
        select?(findFeatureCb?: DataLayerFilter<F, L> | PropertiesFilter): void;
        setData?(geojson: GeoJsonObject): void | Promise<void>;
        setOpacity?(val: number): void;
        setPaint?(paint: Paint): void;
        setSelectedPaint?(paint: Paint): void;
        showLabel?(): void;
        showLayer?(layer?: L): void;
        unselect?(findFeatureCb?: DataLayerFilter<F, L> | PropertiesFilter): void;
        updateLayer?(options?: UpdateLayerAdapterOptions): void;
        updatePaint?(paint: Partial<Paint>): void;
        updateSelectedPaint?(paint: Partial<Paint>): void;
        updateTooltip?(layerDef?: LayerDefinition<F, L>): void;
    }

    Type Parameters

    • M = any
    • L = any
    • O extends VectorAdapterOptions = VectorAdapterOptions
    • F extends Feature = Feature
    • PROP extends Record<string, any> | null = F extends Feature ? F["properties"] : Record<string, string>
    • P extends Record<string, any> = PROP extends null ? Record<string, any> : PROP

    Hierarchy (View Summary)

    Index
    id?: string
    layer?: L
    map?: M
    name?: string
    options: O
    order?: number
    selected?: boolean

    True if there are selected features in the layer

    source?: unknown

    Experimental option, only for MVT. Points to a data source instead of loading data into a layer.

    • Add GeoJson data to layer.

      Parameters

      • geojson: GeoJsonObject

        GeoJson object.

      Returns void | Promise<void>

    • Remove layer data.

      Parameters

      • Optionalcb: (feature: F) => boolean

        Delete only those objects that match the filter.

      Returns void | Promise<void>

    • Ability to filter a layer with a callback function. It is necessary for the adapter to provide access to the layer objects before output to the map. It is not possible to apply such a filter to vector tiles and data on the remote server. So, where possible, use the VectorLayerAdapter.propertiesFilter.

      Parameters

      Returns LayerDefinition<Feature<Geometry, GeoJsonProperties>, L>[]

      layer.filter((e) => e.feature.properties.id === 2011);
      // but in this case it’s better to do so:
      layer.propertiesFilter([['id', 'eq', 2011]])
    • The way to filter layer objects through serializable expressions. To clear the filter, pass null or undefined as the second parameter.

      Parameters

      Returns Promise<void>

      layer.propertiesFilter(['all', ['color', 'eq', 'green'], ['year', 'gt', 2011]]);
      layer.propertiesFilter([[
      'any',
      ['color', 'eq', 'green'],
      ['color', 'eq', 'red']
      ],
      ['year', 'gt', 2011]
      ]);
    • Update layer with new geojson.

      Parameters

      • geojson: GeoJsonObject

        GeoJson object.

      Returns void | Promise<void>