wlzboy
4 天以前 c098f1e3a3e052aa3d65584aae6dc003a70d75ad
app/api/map.js
@@ -8,7 +8,8 @@
  }
  
  return request({
    url: '/system/gps/address/search',
//    url: '/system/gps/address/search',
    url: '/system/gps/tianditu/place/suggestion',
    method: 'get',
    params: {
      keyword: keyword,
@@ -28,9 +29,12 @@
  if (isNaN(lat) || isNaN(lng)) {
    return Promise.reject(new Error('参数无效,经纬度坐标格式错误'))
  }
  /**
   * 这里用到天地图
   */
  return request({
    url: '/system/gps/address/geocoder',
    // url: '/system/gps/address/geocoder',
    url: '/system/gps/tianditu/reverseGeocoding',
    method: 'get',
    params: {
      lat: lat,
@@ -39,6 +43,21 @@
  })
}
export function calculateTianDiTuDistance(fromAddress, toAddress) {
  // 参数验证
  if (!fromAddress || !toAddress) {
    return Promise.reject(new Error('参数不完整,缺少地址'))
  }
  return request({
    url: '/system/gps/tianditu/distance/byAddress',
    method: 'get',
    params: {
      fromAddress: fromAddress,
      toAddress: toAddress
    }
  })
}
// 地图路线规划API(计算两点间距离)
export function calculateDistance(fromLat, fromLng, toLat, toLng) {
  // 参数验证
@@ -56,6 +75,7 @@
  
  return request({
    url: '/system/gps/route/distance',
    // url: '/system/gps/tianditu/byAddress',
    method: 'get',
    params: {
      fromLat: fromLat,
@@ -84,6 +104,9 @@
    }
  })
}
// 别名,与baiduGeocoding功能相同
export const baiduGeocode = baiduGeocoding
// 百度地图路线规划API(计算两个坐标之间的驾车距离)
export function baiduRouteDriving(origin, destination) {
@@ -249,7 +272,7 @@
  })
}
// 天地图地址搜索提示API(输入联想)
// 天地图普通搜索服务API(地址搜索)
export function tiandituPlaceSuggestion(keyWord, region, city, count) {
  // 参数验证
  if (!keyWord) {
@@ -266,4 +289,4 @@
      count: count || 10
    }
  })
}
}