* @function HeatMap.prototype.getLocalXY * @description 地理坐标转为像素坐标。 * @param {Object} coordinate - 坐标位置。
(coordinate)
| 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 |
no test coverage detected