update
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { mapIcon1, mapIcon2, mapIcon3, mapIcon4 } from '/@/components/chinaMap/chinaHooks.ts';
|
||||
import { watchIcon } from '/@/components/secondaryScreen/secondMap/secondMapHooks.ts';
|
||||
import * as turf from '@turf/turf';
|
||||
|
||||
/**
|
||||
* @desc 创建icon
|
||||
@@ -60,3 +61,36 @@ export function createCircle(option) {
|
||||
...option,
|
||||
});
|
||||
}
|
||||
|
||||
export function getLonLat(result = []) {
|
||||
let arr = [];
|
||||
for (let i = 0; i < result.length; i++) {
|
||||
let { lon, lat, lng } = result[i];
|
||||
if (lng) {
|
||||
lon = lng;
|
||||
}
|
||||
if (!lon || !lat) {
|
||||
continue;
|
||||
}
|
||||
let point = turf.point([lon, lat]);
|
||||
arr.push(point);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 根据多点算中心点
|
||||
*/
|
||||
export function getCenter(list = []) {
|
||||
if (!list || !Array.isArray(list)) {
|
||||
return undefined;
|
||||
}
|
||||
if (list.length < 1) {
|
||||
return undefined;
|
||||
}
|
||||
let features = turf.featureCollection(list);
|
||||
let centerObj = turf.center(features);
|
||||
return centerObj?.geometry?.coordinates;
|
||||
}
|
||||
|
||||
// export function
|
||||
Reference in New Issue
Block a user