* @function Graphic.prototype._highLight * @description 高亮显示选中要素。 * @param {Array. } center - 中心点。 * @param {ol.style.Style} image - 点样式。 * @param {OverlayGraphic} selectGraphic - 高效率点图层点要素。 * @param {ol.Pixel} evtPixel - 当前选中的屏幕像素坐标。 * @private
(center, image, selectGraphic, evtPixel)
| 515 | * @private |
| 516 | */ |
| 517 | _highLight(center, image, selectGraphic, evtPixel) { |
| 518 | if (selectGraphic.getStyle() instanceof CloverShape) { |
| 519 | if (this.hitGraphicLayer) { |
| 520 | this.map.removeLayer(this.hitGraphicLayer); |
| 521 | this.hitGraphicLayer = null; |
| 522 | } |
| 523 | var pixel = this.map.getPixelFromCoordinate([center[0], center[1]]); |
| 524 | //点击点与中心点的角度 |
| 525 | evtPixel = evtPixel || [0, 0]; |
| 526 | var angle = (Math.atan2(evtPixel[1] - pixel[1], evtPixel[0] - pixel[0]) / Math.PI) * 180; |
| 527 | angle = angle > 0 ? angle : 360 + angle; |
| 528 | //确定扇叶 |
| 529 | var index = Math.ceil(angle / (image.getAngle() + image.getSpaceAngle())); |
| 530 | //扇叶的起始角度 |
| 531 | var sAngle = (index - 1) * (image.getAngle() + image.getSpaceAngle()); |
| 532 | //渲染参数 |
| 533 | var opts = { |
| 534 | stroke: new StrokeStyle({ |
| 535 | color: '#ff0000', |
| 536 | width: 1 |
| 537 | }), |
| 538 | fill: new FillStyle({ |
| 539 | color: '#0099ff' |
| 540 | }), |
| 541 | radius: image.getRadius(), |
| 542 | angle: image.getAngle(), |
| 543 | eAngle: sAngle + image.getAngle(), |
| 544 | sAngle: sAngle, |
| 545 | rotation: image.getRotation() |
| 546 | }; |
| 547 | if (this.highLightStyle && this.highLightStyle instanceof HitCloverShape) { |
| 548 | opts.stroke = this.highLightStyle.getStroke(); |
| 549 | opts.fill = this.highLightStyle.getFill(); |
| 550 | opts.radius = this.highLightStyle.getRadius(); |
| 551 | opts.angle = this.highLightStyle.getAngle(); |
| 552 | } |
| 553 | var hitGraphic = new OverlayGraphic(new Point(center)); |
| 554 | hitGraphic.setStyle(new HitCloverShape(opts)); |
| 555 | this.hitGraphicLayer = new ImageLayer({ |
| 556 | source: new Graphic({ |
| 557 | map: this.map, |
| 558 | graphics: [hitGraphic] |
| 559 | }) |
| 560 | }); |
| 561 | this.map.addLayer(this.hitGraphicLayer); |
| 562 | } else { |
| 563 | this.selected = selectGraphic; |
| 564 | this.changed(); |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | /** |
| 569 | * @function Graphic.prototype.getGraphicsInExtent |
no test coverage detected