@@ -87,7 +87,7 @@ export class Graphic extends ol.source.ImageCanvas {
87
87
88
88
if ( options . onClick ) {
89
89
me . map . on ( 'click' , function ( e ) {
90
- me . map . forEachFeatureAtPixel ( e . pixel , options . onClick , { } , e ) ;
90
+ me . map . forEachFeatureAtPixel ( e . pixel , options . onClick , { } , e ) ;
91
91
} ) ;
92
92
}
93
93
@@ -151,7 +151,7 @@ export class Graphic extends ol.source.ImageCanvas {
151
151
*/
152
152
function _forEachFeatureAtCoordinate ( coordinate , resolution , callback , evtPixel , e ) {
153
153
let graphics = me . getGraphicsInExtent ( ) ;
154
- let includeGraphics = [ ] ; // 点密集的时候,符合条件的有多个 还需精确计算
154
+ let includeGraphics = [ ] ; // 点密集的时候,符合条件的有多个 还需精确计算
155
155
for ( let i = graphics . length - 1 ; i >= 0 ; i -- ) {
156
156
let style = graphics [ i ] . getStyle ( ) ;
157
157
if ( ! style ) {
@@ -183,7 +183,7 @@ export class Graphic extends ol.source.ImageCanvas {
183
183
for ( let index = 0 ; index < 8 ; index ++ ) {
184
184
const radian = ( ratation + index * perAngle ) / 180 * Math . PI ;
185
185
coors . push ( [ center [ 0 ] + r * Math . cos ( radian ) ,
186
- center [ 1 ] - r * Math . sin ( radian )
186
+ center [ 1 ] - r * Math . sin ( radian )
187
187
] ) ;
188
188
}
189
189
coors . push ( center ) ;
@@ -222,20 +222,20 @@ export class Graphic extends ol.source.ImageCanvas {
222
222
}
223
223
// 精确计算
224
224
let exactGraphic = this . _getExactGraphic ( includeGraphics , evtPixel ) ;
225
- if ( exactGraphic ) {
225
+ if ( exactGraphic ) {
226
226
let _style = exactGraphic . getStyle ( ) ,
227
- _center = exactGraphic . getGeometry ( ) . getCoordinates ( ) ,
228
- _image = new ol . style . Style ( {
229
- image : _style
230
- } ) . getImage ( ) ;
227
+ _center = exactGraphic . getGeometry ( ) . getCoordinates ( ) ,
228
+ _image = new ol . style . Style ( {
229
+ image : _style
230
+ } ) . getImage ( ) ;
231
231
232
232
if ( me . isHighLight ) {
233
233
me . _highLight ( _center , _image , exactGraphic , evtPixel ) ;
234
234
}
235
235
if ( callback ) {
236
236
callback ( exactGraphic , e ) ;
237
- }
238
- } else {
237
+ }
238
+ } else {
239
239
if ( me . isHighLight ) {
240
240
me . _highLightClose ( ) ;
241
241
}
@@ -252,22 +252,22 @@ export class Graphic extends ol.source.ImageCanvas {
252
252
* @param {Array.<ol.Graphic> } graphics - 点要素对象数组。
253
253
* @param {ol.Pixel } evtPixel - 当前选中的屏幕像素坐标。
254
254
*/
255
- _getExactGraphic ( graphics , evtPixel ) {
256
- if ( graphics . length === 0 ) {
255
+ _getExactGraphic ( graphics , evtPixel ) {
256
+ if ( graphics . length === 0 ) {
257
257
return false ;
258
- } else if ( graphics . length === 1 ) {
258
+ } else if ( graphics . length === 1 ) {
259
259
return graphics [ 0 ] ;
260
- } else {
260
+ } else {
261
261
let distances = [ ] ;
262
- graphics . map ( ( graphic , index ) => {
262
+ graphics . map ( ( graphic , index ) => {
263
263
let center = graphic . getGeometry ( ) . getCoordinates ( ) ,
264
- centerPixel = this . map . getPixelFromCoordinate ( center ) ,
265
- distance = Math . sqrt ( Math . pow ( ( centerPixel [ 0 ] - evtPixel [ 0 ] ) , 2 ) + Math . pow ( ( centerPixel [ 1 ] - evtPixel [ 1 ] ) , 2 ) ) ;
266
- distances . push ( { distance : distance , index : index } ) ;
267
- return null ;
264
+ centerPixel = this . map . getPixelFromCoordinate ( center ) ,
265
+ distance = Math . sqrt ( Math . pow ( ( centerPixel [ 0 ] - evtPixel [ 0 ] ) , 2 ) + Math . pow ( ( centerPixel [ 1 ] - evtPixel [ 1 ] ) , 2 ) ) ;
266
+ distances . push ( { distance : distance , index : index } ) ;
267
+ return null ;
268
268
} ) ;
269
269
270
- distances . sort ( ( a , b ) => {
270
+ distances . sort ( ( a , b ) => {
271
271
return a . distance - b . distance
272
272
} ) ;
273
273
return graphics [ distances [ 0 ] . index ] ;
0 commit comments