@@ -8,7 +8,7 @@ import { CloverShape } from './graphic/CloverShape';
8
8
import { CommonUtil } from '@supermap/iclient-common' ;
9
9
import { GraphicWebGLRenderer } from './graphic/WebGLRenderer' ;
10
10
import { GraphicCanvasRenderer } from './graphic/CanvasRenderer' ;
11
- import { Graphic as OverlayGraphic } from './graphic/Graphic' ;
11
+ import { Graphic as OverlayGraphic } from './graphic/Graphic' ;
12
12
import ImageCanvasSource from 'ol/source/ImageCanvas' ;
13
13
import Style from 'ol/style/Style' ;
14
14
import CircleStyle from 'ol/style/Circle' ;
@@ -82,12 +82,29 @@ export class Graphic extends ImageCanvasSource {
82
82
const me = this ;
83
83
84
84
if ( options . onClick ) {
85
- me . map . on ( 'click' , function ( e ) {
86
- me . map . forEachFeatureAtPixel ( e . pixel , options . onClick , { } , e ) ;
85
+ me . map . on ( 'click' , function ( e ) {
86
+ const features = me . map . getFeaturesAtPixel ( e . pixel ) || [ ] ;
87
+ for ( let index = 0 ; index < features . length ; index ++ ) {
88
+ const graphic = features [ index ] ;
89
+ if ( me . graphics . indexOf ( graphic ) > - 1 ) {
90
+ options . onClick ( graphic , e ) ;
91
+ if ( me . isHighLight ) {
92
+ me . _highLight (
93
+ graphic . getGeometry ( ) . getCoordinates ( ) ,
94
+ new Style ( {
95
+ image : graphic . getStyle ( )
96
+ } ) . getImage ( ) ,
97
+ graphic ,
98
+ e . pixel
99
+ ) ;
100
+ }
101
+ }
102
+ break ;
103
+ }
87
104
} ) ;
88
105
}
89
-
90
- function canvasFunctionInternal_ ( extent , resolution , pixelRatio , size , projection ) { // eslint-disable-line no-unused-vars
106
+ //eslint-disable-next-line no-unused-vars
107
+ function canvasFunctionInternal_ ( extent , resolution , pixelRatio , size , projection ) {
91
108
if ( ! me . renderer ) {
92
109
me . renderer = createRenderer ( size , pixelRatio ) ;
93
110
}
@@ -122,10 +139,10 @@ export class Graphic extends ImageCanvasSource {
122
139
opt = CommonUtil . extend ( me , opt ) ;
123
140
opt . pixelRatio = pixelRatio ;
124
141
opt . container = me . map . getViewport ( ) . getElementsByClassName ( 'ol-overlaycontainer' ) [ 0 ] ;
125
- opt . onBeforeRender = function ( ) {
142
+ opt . onBeforeRender = function ( ) {
126
143
return false ;
127
144
} ;
128
- opt . onAfterRender = function ( ) {
145
+ opt . onAfterRender = function ( ) {
129
146
return false ;
130
147
} ;
131
148
@@ -197,9 +214,6 @@ export class Graphic extends ImageCanvasSource {
197
214
}
198
215
199
216
if ( contain === true ) {
200
- if ( me . isHighLight ) {
201
- me . _highLight ( center , image , graphics [ i ] , evtPixel ) ;
202
- }
203
217
if ( callback ) {
204
218
callback ( graphics [ i ] , e ) ;
205
219
}
@@ -522,13 +536,13 @@ export class Graphic extends ImageCanvasSource {
522
536
getGraphicsInExtent ( extent ) {
523
537
var graphics = [ ] ;
524
538
if ( ! extent ) {
525
- this . graphics . map ( function ( graphic ) {
539
+ this . graphics . map ( function ( graphic ) {
526
540
graphics . push ( graphic ) ;
527
541
return graphic ;
528
542
} ) ;
529
543
return graphics ;
530
544
}
531
- this . graphics . map ( function ( graphic ) {
545
+ this . graphics . map ( function ( graphic ) {
532
546
if ( olExtent . containsExtent ( extent , graphic . getGeometry ( ) . getExtent ( ) ) ) {
533
547
graphics . push ( graphic ) ;
534
548
}
0 commit comments