UNPKG

t-comm

Version:

专业、稳定、纯粹的工具库

46 lines (43 loc) 1.51 kB
import _classCallCheck from '@babel/runtime/helpers/classCallCheck'; import _createClass from '@babel/runtime/helpers/createClass'; import { LocationFlag } from '../location-interface.mjs'; var TencentMapApiLocation = /*#__PURE__*/function () { function TencentMapApiLocation() { _classCallCheck(this, TencentMapApiLocation); } return _createClass(TencentMapApiLocation, [{ key: "getLocation", value: function getLocation() { return new Promise(function (resolve, reject) { // @ts-ignore wx.getLocation({ type: 'gcj02', success: function success(res) { var location = { lat: parseFloat("".concat(res.latitude)), lng: parseFloat("".concat(res.longitude)) }; TencentMapApiLocation.lastLocation = location; resolve({ location: location, flag: LocationFlag.LocationSuccess }); }, fail: function fail(error) { console.log('MiniProgramLocation', error); // 频繁调用导致失败,返回最后一次location if (error.errMsg && error.errMsg.indexOf('频繁调用') > -1) { resolve({ location: TencentMapApiLocation.lastLocation, flag: LocationFlag.LocationSuccess }); return; } reject(); } }); }); } }]); }(); export { TencentMapApiLocation as default };