|
|
@@ -1,4 +1,5 @@
|
|
|
import { params } from "@/env";
|
|
|
+import { aMapToWgs84 } from "@/utils/coord";
|
|
|
|
|
|
export type Address = { address: string; latlng: number[]; id: string };
|
|
|
const platform = {
|
|
|
@@ -15,13 +16,21 @@ const platform = {
|
|
|
}
|
|
|
console.log(res);
|
|
|
const items = res.geocodes
|
|
|
- .map((item: any) => ({
|
|
|
- id: item.location,
|
|
|
- address: item.formatted_address,
|
|
|
- latlng: item.location
|
|
|
+ .map((item: any) => {
|
|
|
+ const ll = item.location
|
|
|
.split(",")
|
|
|
- .map((item: string) => Number(item.trim())),
|
|
|
- }))
|
|
|
+ .map((item: string) => Number(item.trim()));
|
|
|
+ const p = aMapToWgs84({
|
|
|
+ x: Number(ll[0]),
|
|
|
+ y: Number(ll[1]),
|
|
|
+ });
|
|
|
+
|
|
|
+ return {
|
|
|
+ id: item.location,
|
|
|
+ address: item.formatted_address,
|
|
|
+ latlng: [p.x, p.y]
|
|
|
+ };
|
|
|
+ })
|
|
|
.slice(0, 10);
|
|
|
return items;
|
|
|
});
|
|
|
@@ -31,7 +40,6 @@ const platform = {
|
|
|
tipParams.set("basic", "y");
|
|
|
tipParams.set("key", val);
|
|
|
tipParams.set("location", "113.05,22.61");
|
|
|
-
|
|
|
const keyList = (await fetch(`/s/api/gettips?${tipParams.toString()}`)
|
|
|
.then((res) => res.json())
|
|
|
.then((res) => res.data)) as { name: string }[];
|
|
|
@@ -54,14 +62,14 @@ const platform = {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- await Promise.all(reqs)
|
|
|
- return items
|
|
|
+ await Promise.all(reqs);
|
|
|
+ return items;
|
|
|
},
|
|
|
};
|
|
|
|
|
|
export const searchAddress = (val: string): Promise<Address[]> => {
|
|
|
if (!val) return Promise.resolve([]);
|
|
|
- console.log(import.meta.env.VITE_MAP_PLATFORM)
|
|
|
+ console.log(import.meta.env.VITE_MAP_PLATFORM);
|
|
|
const p = (
|
|
|
params.mapPlatform && params.mapPlatform in platform
|
|
|
? params.mapPlatform
|