函数s
-
import {add} from 'ol/coordinate';将
delta加到coordinate上。coordinate被原地修改并由函数返回。示例:
import {add} from 'ol/coordinate.js'; const coord = [7.85, 47.983333]; add(coord, [-2, 4]); // coord is now [5.85, 51.983333]Name Type Description coordinateCoordinate 坐标。
deltaCoordinate 增量。
返回值:
由给定增量调整后的输入坐标。
-
import {createStringXY} from 'ol/coordinate';返回一个
CoordinateFormat函数,可用于将 {Coordinate} 格式化为字符串。不指定小数位数的示例:
import {createStringXY} from 'ol/coordinate.js'; const coord = [7.85, 47.983333]; const stringifyFunc = createStringXY(); const out = stringifyFunc(coord); // out is now '8, 48'显式指定 2 位小数的示例:
import {createStringXY} from 'ol/coordinate.js'; const coord = [7.85, 47.983333]; const stringifyFunc = createStringXY(2); const out = stringifyFunc(coord); // out is now '7.85, 47.98'Name Type Description fractionDigitsnumber | undefined 小数点后包含的位数。默认为
0。返回值:
坐标格式。
-
import {format} from 'ol/coordinate';使用给定的字符串模板将
Coordinate转换为字符串。 模板中的{x}和{y}字符串将分别替换为第一个和第二个坐标值。不指定小数位数的示例:
import {format} from 'ol/coordinate.js'; const coord = [7.85, 47.983333]; const template = 'Coordinate is ({x}|{y}).'; const out = format(coord, template); // out is now 'Coordinate is (8|48).'显式指定小数位数的示例:
import {format} from 'ol/coordinate.js'; const coord = [7.85, 47.983333]; const template = 'Coordinate is ({x}|{y}).'; const out = format(coord, template, 2); // out is now 'Coordinate is (7.85|47.98).'Name Type Description coordinateCoordinate 坐标。
templatestring 带有
{x}和{y}占位符的模板字符串, 将分别替换为第一个和第二个坐标值。fractionDigitsnumber | undefined 小数点后包含的位数。默认为
0。返回值:
格式化后的坐标。
-
import {rotate} from 'ol/coordinate';按
angle旋转coordinate。coordinate被原地修改并由函数返回。示例:
import {rotate} from 'ol/coordinate.js'; const coord = [7.85, 47.983333]; const rotate弧度 = Math.PI / 2; // 90 degrees rotate(coord, rotate弧度); // coord is now [-47.983333, 7.85]Name Type Description coordinateCoordinate 坐标。
anglenumber 旋转角度(弧度)。
返回值:
坐标。
-
import {toStringHDMS} from 'ol/coordinate';格式化地理坐标,包含半球、度、分和秒。
不指定小数位数的示例:
import {toStringHDMS} from 'ol/coordinate.js'; const coord = [7.85, 47.983333]; const out = toStringHDMS(coord); // out is now '47° 58′ 60″ N 7° 50′ 60″ E'显式指定 1 位小数的示例:
import {toStringHDMS} from 'ol/coordinate.js'; const coord = [7.85, 47.983333]; const out = toStringHDMS(coord, 1); // out is now '47° 58′ 60.0″ N 7° 50′ 60.0″ E'Name Type Description coordinateCoordinate 坐标。
fractionDigitsnumber | undefined 小数点后包含的位数。默认为
0。返回值:
半球、度、分和秒。
-
import {toStringXY} from 'ol/coordinate';将坐标格式化为逗号分隔的字符串。
不指定小数位数的示例:
import {toStringXY} from 'ol/coordinate.js'; const coord = [7.85, 47.983333]; const out = toStringXY(coord); // out is now '8, 48'显式指定 1 位小数的示例:
import {toStringXY} from 'ol/coordinate.js'; const coord = [7.85, 47.983333]; const out = toStringXY(coord, 1); // out is now '7.8, 48.0'Name Type Description coordinateCoordinate 坐标。
fractionDigitsnumber | undefined 小数点后包含的位数。默认为
0。返回值:
XY 字符串。
Type Definitions
-
Coordinate{Array.<number>}
-
表示
xy、xyz或xyzm坐标的数字数组。 示例:[16, 48]。 -
接受
Coordinate并将其转换为{string}的函数。