Tag: 导航器

启用后,Navigator Geolocation API将引发错误代码PERMISSION_DENIED

我为我的Angular 4项目使用了Navigator Geolocation API,下面是我使用它的一段代码: setLocationByNavigator () { let options = {} const deviceInfo = this.deviceService.getDeviceInfo() if (deviceInfo.device === 'android' || deviceInfo.os === 'mac') { options = { maximumAge: 1500000, timeout: 100000 } } return new Promise((resolve, reject) => { navigator.geolocation.getCurrentPosition((position) => { resolve(position.coords) }, (error: PositionError) => { resolve(error) }, options) }) } getErrorCode (error: […]