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

Method getLocalXY

src/openlayers/overlay/HeatMap.js:325–346  ·  view source on GitHub ↗

* @function HeatMap.prototype.getLocalXY * @description 地理坐标转为像素坐标。 * @param {Object} coordinate - 坐标位置。

(coordinate)

Source from the content-addressed store, hash-verified

323 * @param {Object} coordinate - 坐标位置。
324 */
325 getLocalXY(coordinate) {
326 var pixelP, map = this.map;
327 if (coordinate instanceof GeometryPoint || coordinate instanceof GeoText) {
328 pixelP = map.getPixelFromCoordinate([coordinate.x, coordinate.y]);
329 }
330 if (coordinate instanceof LonLat) {
331 pixelP = map.getPixelFromCoordinate([coordinate.lon, coordinate.lat]);
332 }
333 var rotation = -map.getView().getRotation();
334 var center = map.getPixelFromCoordinate(map.getView().getCenter());
335 var rotatedP = pixelP;
336 if (this.pixelRatio) {
337 rotatedP = this.scale(pixelP, center, this.pixelRatio);
338 }
339 if (pixelP && center) {
340 rotatedP = this.rotate(rotatedP, rotation, center);
341 }
342 if (this.offset && rotatedP) {
343 return [rotatedP[0] + this.offset[0], rotatedP[1] + this.offset[1]];
344 }
345 return rotatedP;
346 }
347
348 /**
349 * @function HeatMap.prototype.rotate

Callers 2

getLabelInfoMethod · 0.45

Calls 3

scaleMethod · 0.95
rotateMethod · 0.95
getViewMethod · 0.80

Tested by

no test coverage detected