获取摄像头:navigator.mediaDevices.getUserMedia()
function openLocalStream(stream) {
console.log('Open local stream':stream);
}
navigator.mediaDevices.getUserMedia({
audio: true,
video: true
})
.then(openLocalStream)
.catch(function (e) {
alert("getUserMedia() error: " + e.name);
});
获取经纬度:navigator.geolocation.getCurrentPosition()
function geoSuccess(position) {
var lat = position.coords.latitude
var lng = position.coords.longitude
return {lat,lng}
}
geoError(error) {
switch (error.code) {
case error.PERMISSION_DENIED:
return alert('定位失败,用户拒绝请求地理定位')
case error.POSITION_UNAVAILABLE:
return alert('定位失败,位置信息是不可用')
case error.TIMEOUT:
return alert('定位失败,请求获取用户位置超时')
case error.UNKNOWN_ERROR:
return alert('定位失败,定位系统失效')
}
}
if(navigator.geolocation){
navigator.geolocation.getCurrentPosition(geoSuccess, geoError)
}else{
alert('浏览器不支持地理定位。')
}
4 条评论
作者对主题的挖掘深入骨髓,展现了非凡的洞察力和理解力。
《有话好好说》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/78137.html
《大清徽商》国产剧高清在线免费观看:https://www.jgz518.com/xingkong/30997.html
《关于无尽》剧情片高清在线免费观看:https://www.jgz518.com/xingkong/7976.html