'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) {
        function geoShowPosition(position) {
          if (position) {
            var location = {
              lat: position.coords.latitude,
              lng: position.coords.longitude
            };
            resolve({
              location: location,
              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);
      });
    }
  }]);
}();

exports["default"] = TencentMapApiLocation;
