MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / getLocalXY

Method getLocalXY

src/openlayers/overlay/theme/Theme.js:477–498  ·  view source on GitHub ↗

* @function Theme.prototype.getLocalXY * @description 地理坐标转为像素坐标。 * @param {Object} coordinate - 坐标位置。 * @returns {Array. } 长度为 2 的像素坐标数组,第一个元素表示 x 坐标,第二个元素表示 y 坐标。

(coordinate)

Source from the content-addressed store, hash-verified

475 * @returns {Array.<number>} 长度为 2 的像素坐标数组,第一个元素表示 x 坐标,第二个元素表示 y 坐标。
476 */
477 getLocalXY(coordinate) {
478 var pixelP, map = this.map;
479 if (coordinate instanceof GeometryPoint || coordinate instanceof GeoText) {
480 pixelP = map.getPixelFromCoordinate([coordinate.x, coordinate.y]);
481 }
482 if (coordinate instanceof LonLat) {
483 pixelP = map.getPixelFromCoordinate([coordinate.lon, coordinate.lat]);
484 }
485 var rotation = -map.getView().getRotation();
486 var center = map.getPixelFromCoordinate(map.getView().getCenter());
487 var rotatedP = pixelP;
488 if (this.pixelRatio) {
489 rotatedP = this.scale(pixelP, center, this.pixelRatio);
490 }
491 if (pixelP && center) {
492 rotatedP = this.rotate(rotatedP, rotation, center);
493 }
494 if (this.offset && rotatedP) {
495 return [rotatedP[0] + this.offset[0], rotatedP[1] + this.offset[1]];
496 }
497 return rotatedP;
498 }
499
500 /**
501 * @function Theme.prototype.rotate

Callers

nothing calls this directly

Calls 3

scaleMethod · 0.95
rotateMethod · 0.95
getViewMethod · 0.80

Tested by

no test coverage detected