SDK JS
    Preparing search index...

    Function setWidgetStyleNonce

    • Set the CSP nonce stamped on every widget <style> element.

      Parameters

      • value: string | undefined

        The nonce for this page load, or undefined to stop stamping one.

      Returns void

      Call once, before adding any widget, on a page whose Content-Security-Policy uses a nonce-based style-src. Widgets already on the page keep the nonce they were injected with — a nonce is only honoured at insertion, so re-stamping an existing element would do nothing and pretending otherwise would be worse than not offering it.

      If your policy has no nonce and forbids inline styles entirely, use bitruviusWidgetCss to ship the CSS through your own build instead.

      setWidgetStyleNonce(document.querySelector('meta[name=csp-nonce]')?.getAttribute('content') ?? undefined);
      map.addControl(new LayerSettingsWidget({ … }));