Methods
-
Add
delta
tocoordinate
.coordinate
is modified in place and returned by the function.Example:
var coord = [7.85, 47.983333]; ol.coordinate.add(coord, [-2, 4]); // coord is now [5.85, 51.983333]
Name Type Description coordinate
ol.Coordinate Coordinate.
delta
ol.Coordinate Delta.
Returns:
The input coordinate adjusted by the given delta.
-
ol.coordinate.createStringXY(opt_fractionDigits){ol.CoordinateFormatType}
src/ol/coordinate.js, line 122 -
Returns a
ol.CoordinateFormatType
function that can be used to format a {ol.Coordinate} to a string.Example without specifying the fractional digits:
var coord = [7.85, 47.983333]; var stringifyFunc = ol.coordinate.createStringXY(); var out = stringifyFunc(coord); // out is now '8, 48'
Example with explicitly specifying 2 fractional digits:
var coord = [7.85, 47.983333]; var stringifyFunc = ol.coordinate.createStringXY(2); var out = stringifyFunc(coord); // out is now '7.85, 47.98'
Name Type Description fractionDigits
number The number of digits to include after the decimal point. Default is
0
.Returns:
Coordinate format.
-
ol.coordinate.format(coordinate, template, opt_fractionDigits){string}
src/ol/coordinate.js, line 195 -
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).'
Name Type Description coordinate
ol.Coordinate | undefined Coordinate.
template
string A template string with
{x}
and{y}
placeholders that will be replaced by first and second coordinate values.fractionDigits
number The number of digits to include after the decimal point. Default is
0
.Returns:
Formatted coordinate.
-
Rotate
coordinate
byangle
.coordinate
is modified in place and returned by the function.Example:
var coord = [7.85, 47.983333]; var rotateRadians = Math.PI / 2; // 90 degrees ol.coordinate.rotate(coord, rotateRadians); // coord is now [-47.983333, 7.85]
Name Type Description coordinate
ol.Coordinate Coordinate.
angle
number Angle in radian.
Returns:
Coordinate.
-
ol.coordinate.toStringHDMS(coordinate, opt_fractionDigits){string}
src/ol/coordinate.js, line 344 -
Format a geographic coordinate with the hemisphere, degrees, minutes, and seconds.
Example without specifying fractional digits:
var coord = [7.85, 47.983333]; var out = ol.coordinate.toStringHDMS(coord); // out is now '47° 58′ 60″ N 7° 50′ 60″ E'
Example explicitly specifying 1 fractional digit:
var coord = [7.85, 47.983333]; var out = ol.coordinate.toStringHDMS(coord, 1); // out is now '47° 58′ 60.0″ N 7° 50′ 60.0″ E'
Name Type Description coordinate
ol.Coordinate | undefined Coordinate.
fractionDigits
number The number of digits to include after the decimal point. Default is
0
.Returns:
Hemisphere, degrees, minutes and seconds.
-
ol.coordinate.toStringXY(coordinate, opt_fractionDigits){string}
src/ol/coordinate.js, line 375 -
Format a coordinate as a comma delimited string.
Example without specifying fractional digits:
var coord = [7.85, 47.983333]; var out = ol.coordinate.toStringXY(coord); // out is now '8, 48'
Example explicitly specifying 1 fractional digit:
var coord = [7.85, 47.983333]; var out = ol.coordinate.toStringXY(coord, 1); // out is now '7.8, 48.0'
Name Type Description coordinate
ol.Coordinate | undefined Coordinate.
fractionDigits
number The number of digits to include after the decimal point. Default is
0
.Returns:
XY.