MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / getLocalXY

Method getLocalXY

src/common/overlay/feature/Theme.js:94–109  ·  view source on GitHub ↗

* @function FeatureTheme.prototype.getLocalXY * @description 地理坐标转为像素坐标。 * @param {GeometryPoint|GeometryGeoText|LonLat} coordinate - 地理坐标点。 * @returns {Array. } 长度为 2 的像素坐标数组,第一个元素表示 x 坐标,第二个元素表示 y 坐标。

(coordinate)

Source from the content-addressed store, hash-verified

92 * @returns {Array.<number>} 长度为 2 的像素坐标数组,第一个元素表示 x 坐标,第二个元素表示 y 坐标。
93 */
94 getLocalXY(coordinate) {
95 var resolution = this.layer.map.getResolution();
96 var extent = this.layer.map.getExtent();
97
98 if (coordinate instanceof Point || coordinate instanceof GeoText) {
99 let x = (coordinate.x / resolution + (-extent.left / resolution));
100 let y = ((extent.top / resolution) - coordinate.y / resolution);
101 return [x, y];
102 } else if (coordinate instanceof LonLat) {
103 let x = (coordinate.lon / resolution + (-extent.left / resolution));
104 let y = ((extent.top / resolution) - coordinate.lat / resolution);
105 return [x, y];
106 } else {
107 return null;
108 }
109 }
110
111}

Callers

nothing calls this directly

Calls 1

getExtentMethod · 0.45

Tested by

no test coverage detected