* @function FeatureThemeGraph.prototype.resetLocation * @description 根据地理位置 lonlat 重置专题要素(图表)位置。 * @param {LonLat} lonlat - 专题要素新的像素中心位置。 * @returns {Array. } 新专题要素像素参考位置。长度为 2 的数组,第一个元素表示 x 坐标,第二个元素表示 y 坐标。
(lonlat)
| 348 | * @returns {Array.<number>} 新专题要素像素参考位置。长度为 2 的数组,第一个元素表示 x 坐标,第二个元素表示 y 坐标。 |
| 349 | */ |
| 350 | resetLocation(lonlat) { |
| 351 | if (lonlat) { |
| 352 | this.lonlat = lonlat; |
| 353 | } |
| 354 | |
| 355 | // 获取地理位置对应的像素坐标 newLocalLX |
| 356 | var newLocalLX = this.getLocalXY(this.lonlat); |
| 357 | // 处理偏移量 XOffset, YOffset |
| 358 | newLocalLX[0] += this.XOffset; |
| 359 | newLocalLX[1] += this.YOffset; |
| 360 | // 将图形位置赋予 location 属性(注意 location 属性表示的是专题要素中心位置) |
| 361 | this.location = newLocalLX; |
| 362 | |
| 363 | // 更新图表像素 Bounds |
| 364 | var w = this.width; |
| 365 | var h = this.height; |
| 366 | var loc = this.location; |
| 367 | this.chartBounds = new Bounds(loc[0] - w / 2, loc[1] + h / 2, loc[0] + w / 2, loc[1] - h / 2); |
| 368 | |
| 369 | //重新计算当前渐变色 |
| 370 | this.resetLinearGradient(); |
| 371 | |
| 372 | return loc; |
| 373 | } |
| 374 | |
| 375 | /** |
| 376 | * @function FeatureThemeGraph.prototype.resetLinearGradient |
no test coverage detected