UNPKG

react-native-position

Version:
38 lines (37 loc) 986 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HMSLocation = HMSLocation; function HMSLocation(hmsKey, cellInfos, wifiInfos) { console.log('cellInfos', cellInfos); console.log('wifiInfos', wifiInfos); return fetch('https://locationapi.cloud.huawei.com/networklocation/v1/geoLocation', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${hmsKey}` }, body: JSON.stringify({ boottime: Date.now() * 1000, indoorMode: 0, cellInfos, wifiInfos }) }).then(res => res.json()).then(res => { if (res.errorCode !== '0') { throw Error('HMSResult:' + JSON.stringify({ errorCode: res.errorCode, errorMsg: res.errorMsg, cellInfos, wifiInfos })); } return { longitude: res.position.lon, latitude: res.position.lat, HMSResult: res }; }); } //# sourceMappingURL=HMSLocation.js.map