UNPKG

t-comm

Version:

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

44 lines (39 loc) 1.39 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var location_locationInterface = require('../location-interface.js'); var TencentMapApiLocation = /** @class */function () { function TencentMapApiLocation() {} TencentMapApiLocation.prototype.getLocation = function () { 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(); } }); }); }; return TencentMapApiLocation; }(); exports["default"] = TencentMapApiLocation;