现在,针对getCurrentLocation的React本机项目工作实现会因密码错误而失败

时间:2018-12-19 02:06:25

标签: react-native geolocation

对于getCurrentLocation的反应本机项目工作实现现在失败,并出现隐秘错误,我正在传递给console.log:

TypeError: Network request failed
    at XMLHttpRequest.xhr.onerror (browser-ponyfill.js:475)
    at XMLHttpRequest.dispatchEvent (event-target.js:172)
    at XMLHttpRequest.setReadyState (XMLHttpRequest.js:580)
    at XMLHttpRequest.__didCompleteResponse (XMLHttpRequest.js:394)
    at XMLHttpRequest.js:507
    at RCTDeviceEventEmitter.emit (EventEmitter.js:190)
    at MessageQueue.__callFunction (MessageQueue.js:349)
    at MessageQueue.js:106
    at MessageQueue.__guard (MessageQueue.js:297)
    at MessageQueue.callFunctionReturnFlushedQueue (MessageQueue.js:105)

这是我正在使用的代码,导致此问题:

        const 
          resolve = (position) => {
            latitude = position.coords.latitude;
            longitude = position.coords.longitude;
            timestamp = position.timestamp;
            setLatLonGlobally({ latitude, longitude, timestamp });
          },
          reject = (error) => console.log('LOCATION ERROR', error),
          getPosition = () => {
            return new Promise(function (resolve, reject) {
              navigator.geolocation.getCurrentPosition(resolve, reject);
            });
          };
        getPosition()
          .then(position => resolve(position))
          .then(() => fetchMarkers())
          .catch(error => reject(error));

我们非常感谢您的帮助。预先感谢!

0 个答案:

没有答案