A base class for Fixture subclasses. It provides some utility functions to Fixtures and also gives access to $iApi and $vApp globals.

FixtureInstance

Hierarchy (view full)

Constructors

Properties

The instance of RampMap API scoped to a single Vue R4MP application.

APIScope

customRendererFunc: undefined | RenderCallback = ...
fcFabric: undefined | StaticCanvas
fcFabricDownload: undefined | StaticCanvas
id: string

ID of this fixture.

FixtureInstance

options: {
    runningHeight: number;
    scale: number;
} = ...
persist: boolean

Indicates whether to keep the fixture when the language changes. Defaults to true. If only one config is provided for all languages, the fixture will be kept on language change, regardless of the value of the flag.

Fixture

Accessors

  • get $element(): App<Element>
  • Returns App<Element>

  • get $vApp(): ComponentPublicInstance
  • The instance of Vue R4MP application controlled by this InstanceAPI. This is just a shorthand for this.$iApi.$vApp.

    Returns ComponentPublicInstance

    APIScope

Methods

  • Parses the export config JSON snippet from the config file and save to the fixture store.

    Parameters

    Returns void

    ExportAPI

  • Allows for a custom render callback function to be passed in to render the export canvas. The function should accept the blank ramp canvas as its first parameter and use that canvas to draw on. The width of the canvas is already set to the panel width, so the function only needs to set the height.

    Individual export elements like the map or the legend can be accessed from the fabricObjects object as the second parameter. You can pick and chose which elements to add to the canvas, or modify them as needed. You can also add custom elements to the canvas.

    Finally, the options object is passed in as the third parameter. This object contains useful information such as the panel width, the default margins, the default canvas width, and the fabric object itself.

    Some canvas operations are asynchronous like fetching an image or cloning objects. In these cases you should return a promise so ramp waits for your operations to complete, otherwise returning nothing (void) is fine.

    ramp uses Fabric.js instead of the native canvas API. Read more about Fabric.js here: Fabric.js

    Parameters

    • renderCallback: RenderCallback

    Returns void

    myWatermarkingRenderer((canvas, fabricObjects, options) => {
    const watermark = new fabric.Text('Watermark', { ... });
    fabricObjects.map.addWithUpdate(watermark);
    canvas.add(fabricObjects.map);
    canvas.setHeight(1000);
    });

    rInstance.fixture.isLoaded('export').then(() => {
    rInstance.fixture.get('export').customRenderer(myWatermarkingRenderer);
    });

    ExportAPI

  • A helper function to create a "subclass" of the base Vue constructor

    Parameters

    • vueComponent: Record<string, any>
    • Optionaloptions: ComponentOptions = {}

    Returns any

    FixtureInstance

  • Get this fixture's config from the layer config with the given layer id Will return undefined if layer config did not specify a config for this fixture

    Parameters

    • layerId: string

      The layer's id

    Returns any

    This fixture's config for the given layer

  • Combines this fixtures configs from layer configs into an indexed-dictionary

    Returns {
        [layerId: string]: any;
    }

    Dictionary where key is the layer id and the value is this fixture's config for that layer

    • [layerId: string]: any
  • If the panelTeleport property is provided, handle specified panelTeleport for the given fixture.

    Parameters

    • panels: string[]

      list of panel names for the calling fixture

    Returns void

  • If the panelWidth property is provided, handle default and specified panel widths for the given fixture.

    Parameters

    • panels: string[]

      list of panel names for the calling fixture

    Returns void

  • [Optional] Called after the core map logic has executed. If the fixture is added after the map initialization, this is called immediately.

    At this point, any custom content (panels, on-map components, etc.) can be added to R4MP. Custom content can also be added throughout the life of the [module].

    Returns void

    Fixture

  • Creates an export canvas.

    Parameters

    • canvas: HTMLCanvasElement
    • panelWidth: number

    Returns Promise<void>

    ExportAPI

  • Helper with programatically creating a component in Vue 3 (replaces the deprecated Vue.extend)

    Parameters

    • component: Component
    • __namedParameters: any = {}

    Returns {
        destroy: (() => void);
        el: any;
        vNode: any;
    }

    • destroy: (() => void)
        • (): void
        • Returns void

    • el: any
    • vNode: any

    FixtureInstance

  • Removes the specified fixture from R4MP instance. This is a proxy to rInstance.fixture.remove(...).

    Returns this

    FixtureInstance

  • Adds missing functions and properties to the object implementing FixtureBase interface. This is only needed for external fixtures as they can't inherit from FixtureInstance.

    TODO: If you know a better way to deep-mixin props/getters/functions from a class into another class instance, please tell me. I honestly don't know 🤷‍♂️.

    Parameters

    Returns FixtureInstance

    FixtureInstance