Skip to content

Commit 1dd5b98

Browse files
committed
【fix】兼容轴方向是ne*的投影坐标转换后得到的坐标是y,x的情况 review by xiongjj
1 parent 8ed2e3f commit 1dd5b98

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/mapboxgl/web-map/WebMapViewModel.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,12 @@ export default class WebMapViewModel extends WebMapBase {
16851685
return point;
16861686
}
16871687
// @ts-ignore
1688-
return proj4(sourceProjection, 'EPSG:4326', point);
1688+
const coor = proj4(sourceProjection, 'EPSG:4326', point);
1689+
const proj = proj4.defs(sourceProjection);
1690+
if (proj.axis && proj.axis.indexOf('ne') === 0) {
1691+
coor.reverse();
1692+
}
1693+
return coor;
16891694
}
16901695

16911696
private _getMapCenter(mapInfo) {

static/libs/json-sql/jsonsql.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,23 @@ window.jsonsql = {
6363
// }
6464
// }
6565
// fix with -- stric mode
66-
if (this.functionreplaceWith(jsonsql_scope[jsonsql_i], jsonsql_o.where)) {
66+
if (this.functionWith(jsonsql_scope[jsonsql_i], jsonsql_o.where)) {
6767
jsonsql_result[jsonsql_rc++] = this.returnFields(jsonsql_scope[jsonsql_i], jsonsql_o.fields);
6868
}
6969
}
7070

7171
return jsonsql_result;
7272
},
73+
functionWith(scope, exp) {
74+
if (!scope) return;
7375

74-
functionreplaceWith: function(scope, exp) {
75-
exp = ' ' + exp.trim();
76-
let quickRegex = /([\s\+\-\*\/%&\|\^!\*~]\s*?)([a-zA-Z_$][a-zA-Z_$0-9]*?)/g;
77-
exp = exp.replace(quickRegex, (a, b, c) => {
78-
return b + 'scope.' + c;
79-
});
80-
let func = new Function('scope', 'return ' + exp);
81-
return func(scope);
76+
var resetArgs = '';
77+
for (var key in scope) {
78+
resetArgs = resetArgs + 'var ' + key + ' = _$_$_functionWith["' + key + '"];';
79+
}
80+
var nf = new Function('_$_$_functionWith', resetArgs + 'return ' + exp);
81+
82+
return nf(scope);
8283
},
8384

8485
returnFields: function(scope, fields) {

0 commit comments

Comments
 (0)