UNPKG

@degal-helper/formatlnglat

Version:

格式化经纬度

8 lines (6 loc) 310 B
const formatLngLat = (lnglat, type, fixed = 2) => { const fotmatLngLat = Number(lnglat).toFixed(fixed) const str = fotmatLngLat > 0 ? (type === 'lat' ? '北纬' : '东经') : type === 'lat' ? '南纬' : '西经' return `${str} ${Math.abs(fotmatLngLat).toFixed(fixed)} 度` } export default formatLngLat