t-comm
Version:
专业、稳定、纯粹的工具库
36 lines (31 loc) • 1.1 kB
JavaScript
;
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) {
function geoShowPosition(position) {
if (position) {
var location_1 = {
lat: position.coords.latitude,
lng: position.coords.longitude
};
resolve({
location: location_1,
flag: location_locationInterface.LocationFlag.LocationSuccess
});
} else {
reject();
}
}
function geoShowError(error) {
console.log("getPosError:".concat(error.code, ",").concat(navigator.geolocation, ",").concat(error.message));
reject();
}
navigator.geolocation.getCurrentPosition(geoShowPosition, geoShowError);
});
};
return TencentMapApiLocation;
}();
exports["default"] = TencentMapApiLocation;