getLocation.ts 602 字节
Newer Older
fxy060608's avatar
fxy060608 已提交
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
import { ApiProtocol, ApiOptions } from '../type'

const coordTypes = {
  WGS84: 'WGS84',
  GCJ02: 'GCJ02'
}

export const GetLocationOptions: ApiOptions = {
  formatArgs: {
    type(value, params) {
      value = (value || '').toUpperCase()
      let type = coordTypes[value as keyof typeof coordTypes]
      if (!type) {
        type = coordTypes.WGS84
      }
      params.type = type
    }
  }
}

export const GetLocationProtocol: ApiProtocol = {
  type: {
    type: String,
    default: coordTypes.WGS84
  },
  altitude: {
    type: Boolean,
    default: false
  }
}