• Transforms the given ol.Coordinate to a string using the given string template. The strings {x} and {y} in the template will be replaced with the first and second coordinate values respectively.

    Example without specifying the fractional digits:

    var coord = [7.85, 47.983333];
    var template = 'Coordinate is ({x}|{y}).';
    var out = ol.coordinate.format(coord, template);
    // out is now 'Coordinate is (8|48).'

    Example explicitly specifying the fractional digits:

    var coord = [7.85, 47.983333];
    var template = 'Coordinate is ({x}|{y}).';
    var out = ol.coordinate.format(coord, template, 2);
    // out is now 'Coordinate is (7.85|47.98).'

    Parameters

    • coordinate: Coordinate

      Coordinate.

    • template: string

      A template string with {x} and {y} placeholders that will be replaced by first and second coordinate values.

    • Optional opt_fractionDigits: number

      The number of digits to include after the decimal point. Default is 0.

    Returns string

    Formatted coordinate.

    Api

    stable

Generated using TypeDoc