wlzboy
2025-10-19 3328aec7bc4cc2c090f015cba905a82d6d52870c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import request from '@/utils/request'
 
// 地图地址搜索API
export function searchAddress(keyword, region) {
  // 参数验证
  if (!keyword) {
    return Promise.reject(new Error('参数不完整,缺少关键词'))
  }
  
  return request({
    url: '/system/gps/address/search',
    method: 'get',
    params: {
      keyword: keyword,
      region: region || '广州'
    }
  })
}
 
// 地图逆地址解析API
export function reverseGeocoder(lat, lng) {
  // 参数验证
  if (lat === undefined || lat === null || lng === undefined || lng === null) {
    return Promise.reject(new Error('参数不完整,缺少经纬度坐标'))
  }
  
  // 检查参数有效性
  if (isNaN(lat) || isNaN(lng)) {
    return Promise.reject(new Error('参数无效,经纬度坐标格式错误'))
  }
  
  return request({
    url: '/system/gps/address/geocoder',
    method: 'get',
    params: {
      lat: lat,
      lng: lng
    }
  })
}
 
// 地图路线规划API(计算两点间距离)
export function calculateDistance(fromLat, fromLng, toLat, toLng) {
  // 参数验证
  if (fromLat === undefined || fromLat === null || 
      fromLng === undefined || fromLng === null ||
      toLat === undefined || toLat === null ||
      toLng === undefined || toLng === null) {
    return Promise.reject(new Error('参数不完整,缺少起点或终点坐标'))
  }
  
  // 检查参数有效性
  if (isNaN(fromLat) || isNaN(fromLng) || isNaN(toLat) || isNaN(toLng)) {
    return Promise.reject(new Error('参数无效,坐标格式错误'))
  }
  
  return request({
    url: '/system/gps/route/distance',
    method: 'get',
    params: {
      fromLat: fromLat,
      fromLng: fromLng,
      toLat: toLat,
      toLng: toLng
    }
  })
}