UNPKG

t-comm

Version:

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

55 lines (48 loc) 1.98 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var _classCallCheck = require('@babel/runtime/helpers/classCallCheck'); var _createClass = require('@babel/runtime/helpers/createClass'); var location_locationInterface = require('../location-interface.js'); function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } var _classCallCheck__default = /*#__PURE__*/_interopDefaultLegacy(_classCallCheck); var _createClass__default = /*#__PURE__*/_interopDefaultLegacy(_createClass); var TencentMapApiLocation = /*#__PURE__*/function () { function TencentMapApiLocation() { _classCallCheck__default["default"](this, TencentMapApiLocation); } return _createClass__default["default"](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: location_locationInterface.LocationFlag.LocationSuccess }); }, fail: function fail(error) { console.log('MiniProgramLocation', error); // 频繁调用导致失败,返回最后一次location if (error.errMsg && error.errMsg.indexOf('频繁调用') > -1) { resolve({ location: TencentMapApiLocation.lastLocation, flag: location_locationInterface.LocationFlag.LocationSuccess }); return; } reject(); } }); }); } }]); }(); exports["default"] = TencentMapApiLocation;