UNPKG

t-comm

Version:

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

58 lines (53 loc) 2.08 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var city_city = require('../../city/city.js'); var loader_loaderUnity = require('../../loader/loader-unity.js'); var location_locationInterface = require('../location-interface.js'); require('../../city/data.js'); require('../../tslib.es6-01322ba9.js'); require('../../loader/little-loader.js'); require('../../loader/loader.js'); // 用腾讯地图sdk获取lbs地址 var TencentMapLocation = /** @class */function () { function TencentMapLocation() {} TencentMapLocation.prototype.getLocation = function (options) { return new Promise(function (resolve, reject) { function geoShowPosition(location) { if (!!location.province && !!location.city) { var retList = city_city.getAreaCode(location.province, location.city); if (retList.length > 1) { location.provinceId = retList[0] || 0; location.cityId = retList[1] || 0; } } if (location && location.type !== 'ip') { // 拒绝定位会使用ip地址定位 resolve({ location: location, flag: location_locationInterface.LocationFlag.LocationSuccess }); } else if (location) { resolve({ location: location, flag: location_locationInterface.LocationFlag.LocationIpSuccess }); } else { reject(); } } function geoShowError() { reject(); } loader_loaderUnity.loader('https://3gimg.qq.com/lightmap/components/geolocation/geolocation.min.js', function () { // @ts-ignore var geolocation = new window.qq.maps.Geolocation(location_locationInterface.tencentMapConfig.GEO_KEY, location_locationInterface.tencentMapConfig.GEO_REFERER); var tencentMapOptions = { timeout: options.timeout }; geolocation.getLocation(geoShowPosition, geoShowError, tencentMapOptions); }); }); }; return TencentMapLocation; }(); exports["default"] = TencentMapLocation;