function getLegendUrl(options, resolution) {
  if (options.url === undefined) {
    return undefined;
  }

  const baseParams = {
    'SERVICE': 'WMS',
    'VERSION': DEFAULT_VERSION,
    'REQUEST': 'GetLegendGraphic',
    'FORMAT': 'image/png',
  };

  if (resolution !== undefined) {
    const mpu =
      getProjection(options.projection || 'EPSG:3857').getMetersPerUnit() || 1;
    const pixelSize = 0.00028;
    baseParams['SCALE'] = (resolution * mpu) / pixelSize;
  }

  Object.assign(baseParams, options.params);

  if (options.params !== undefined && baseParams['LAYER'] === undefined) {
    const layers = baseParams['LAYERS'];
    const isSingleLayer = !Array.isArray(layers) || layers.length !== 1;
    if (!isSingleLayer) {
      return undefined;
    }
    baseParams['LAYER'] = layers;
  }

  return appendParams(options.url, baseParams);
}
Get the GetLegendGraphic URL, optionally optimized for the passed resolution and possibly
including any passed specific parameters. Returns `undefined` if the GetLegendGraphic URL
cannot be constructed.

@param {LoaderOptions} options Options passed the `createWMSLoader()` function.
@param {number} [resolution] Resolution. If not provided, `SCALE` will not be calculated and
included in URL.
@return {string|undefined} GetLegendGraphic URL.
@api