Skip to content

Commit 49d8bd4

Browse files
committed
[update] 格式化代码
1 parent 7d054f1 commit 49d8bd4

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/openlayers/overlay/Graphic.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class Graphic extends ol.source.ImageCanvas {
8787

8888
if (options.onClick) {
8989
me.map.on('click', function (e) {
90-
me.map.forEachFeatureAtPixel(e.pixel, options.onClick,{},e);
90+
me.map.forEachFeatureAtPixel(e.pixel, options.onClick, {}, e);
9191
});
9292
}
9393

@@ -151,7 +151,7 @@ export class Graphic extends ol.source.ImageCanvas {
151151
*/
152152
function _forEachFeatureAtCoordinate(coordinate, resolution, callback, evtPixel, e) {
153153
let graphics = me.getGraphicsInExtent();
154-
let includeGraphics = []; // 点密集的时候,符合条件的有多个 还需精确计算
154+
let includeGraphics = []; // 点密集的时候,符合条件的有多个 还需精确计算
155155
for (let i = graphics.length - 1; i >= 0; i--) {
156156
let style = graphics[i].getStyle();
157157
if (!style) {
@@ -183,7 +183,7 @@ export class Graphic extends ol.source.ImageCanvas {
183183
for (let index = 0; index < 8; index++) {
184184
const radian = (ratation + index * perAngle) / 180 * Math.PI;
185185
coors.push([center[0] + r * Math.cos(radian),
186-
center[1] - r * Math.sin(radian)
186+
center[1] - r * Math.sin(radian)
187187
]);
188188
}
189189
coors.push(center);
@@ -222,20 +222,20 @@ export class Graphic extends ol.source.ImageCanvas {
222222
}
223223
// 精确计算
224224
let exactGraphic = this._getExactGraphic(includeGraphics, evtPixel);
225-
if(exactGraphic){
225+
if (exactGraphic) {
226226
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();
231231

232232
if (me.isHighLight) {
233233
me._highLight(_center, _image, exactGraphic, evtPixel);
234234
}
235235
if (callback) {
236236
callback(exactGraphic, e);
237-
}
238-
}else{
237+
}
238+
} else {
239239
if (me.isHighLight) {
240240
me._highLightClose();
241241
}
@@ -252,22 +252,22 @@ export class Graphic extends ol.source.ImageCanvas {
252252
* @param {Array.<ol.Graphic>} graphics - 点要素对象数组。
253253
* @param {ol.Pixel} evtPixel - 当前选中的屏幕像素坐标。
254254
*/
255-
_getExactGraphic(graphics, evtPixel){
256-
if(graphics.length === 0){
255+
_getExactGraphic(graphics, evtPixel) {
256+
if (graphics.length === 0) {
257257
return false;
258-
}else if(graphics.length === 1){
258+
} else if (graphics.length === 1) {
259259
return graphics[0];
260-
} else{
260+
} else {
261261
let distances = [];
262-
graphics.map((graphic, index) =>{
262+
graphics.map((graphic, index) => {
263263
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;
268268
});
269269

270-
distances.sort( (a,b) =>{
270+
distances.sort((a, b) => {
271271
return a.distance - b.distance
272272
});
273273
return graphics[distances[0].index];

0 commit comments

Comments
 (0)