js实现获取手机gps经纬度位置和陀螺仪数据实现指南针和水平仪效果代码
代码语言:html
所属分类:其他
代码描述:js实现获取手机gps经纬度位置和陀螺仪数据实现指南针和水平仪效果代码,请在手机上预览。
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
* {
padding: 0px;
margin: 0px;
list-style: none;
}
:root,
body {
height: 100%;
}
body {
height: 100%;
display: flex;
justify-content: center;
}
.show {
height: 95%;
width: 350px;
transform: translate3D(0px, 20px, 0px);
}
.wrapper {
position: relative;
width: 700px;
height: 100%;
display: flex;
}
/* 第二页水平仪 */
.wrapper .gradienter-out {
position: relative;
height: 100%;
width: 350px;
}
.wrapper .gradienter-out span {
position: absolute;
left: calc(50% - 50px);
top: calc(50% - 50px);
height: 100px;
width: 100px;
border-radius: 50%;
}
.wrapper .gradienter-out span div {
position: absolute;
height: 50px;
width: 100px;
top: calc(50% - 25px);
text-align: center;
line-height: 50px;
font-size: 30px;
font-weight: bold;
transform-origin: center center;
}
/* 第一页 */
.box {
position: relative;
width: 350px;
height: 100%;
}
/* 方向文字、经纬度 */
.box .text {
position: absolute;
width: 350px;
height: 120px;
left: calc(50% - 175px);
top: 20px;
font-size: 13px;
font-weight: bold;
}
.box .text .direction-angle {
height: 50px;
line-height: 50px;
text-align: center;
font-size: 30px;
margin-bottom: 10px;
}
.box .text .latitude {
float: left;
margin-left: 50px;
color: rgba(0, 0, 0, .5)
}
.box .text .longitude {
float: right;
margin-right: 50px;
color: rgba(0, 0, 0, .5)
}
/* 指针 */
.box .point {
position: absolute;
height: 25px;
width: 2px;
left: 50%;
top: 165px;
background-color: black;
z-index: 10;
}
/* 表盘 */
.box .dial {
position: relative;
height: 300px;
width: 300px;
top: 170px;
left: calc(50% - 155px);
transform-origin: 158px 111px;
}
/* 外圈表盘刻度 */
.box .dial .scale {
position: absolute;
height: 300px;
width: 300px;
border-radius: 50%;
transform-origin: 150px 150px;
transform: translatez(0px) rotate(11deg);
}
/* 小刻度 */
.box .dial .scale ul li {
position: absolute;
left: calc(50% - 1px);
width: 2px;
height: 10px;
background-color: #ddd;
transform-origin: center 110px;
}
/* 中刻度 */
.box .dial .scale ul li:nth-of-type(5n) {
height: 12px;
}
/* 大刻度 */
.box .dial .scale ul li:nth-of-type(10n) {
height: 15px;
background-color: rgba(0, 0, 0, .5);
}
/* 数字和方向 */
.box .dial .num ul li,
.box .dial .num .direction {
position: absolute;
height: 25px;
width: 34px;
left: calc(50% - 10px);
top: 20px;
text-align: center;
line-height: 25px;
font-family: '宋体';
font-weight: 500;
font-size: 10px;
transform-origin: center 90px;
}
.box .dial .num .direction {
top: 55px;
transform-origin: center 55px;
}
/* 红色小标记 */
.dial .num .sign {
position: absolute;
left: calc(50% - 4px);
top: 30px;
border-top: 10px solid transparent;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid red;
}
.dial .num .direction span {
position: absolute;
display: block;
height: 100%;
width: 100%;
text-align: center;
transform-origin: center;
}
.north {
color: red;
}
.box .gradienter-in {
position: relative;
left: calc(50% - 10px);
top: -6%;
height: 30px;
width: 30px;
border-radius: 50%;
box-sizing: border-box;
transform-origin: center;
}
.note{
text-align: center;
margin-top: 50px;
color: grey;
}
</style>
</head>
<body>
&.........完整代码请登录后点击上方下载按钮下载查看
网友评论0