秀米打卡第十五天

点击开窗和之前的部分SVG效果设置还是差不多的。可以根据自己的需要来更改图片,两张图片的高度最好也设置一致。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个基于 JavaScript 的示例代码,用于检测用户当前位置是否在中心点500米的范围内,并在范围内显示打卡成功提示: ```javascript // 定义中心点经纬度 const centerLatitude = 37.774929; const centerLongitude = -122.419416; // 获取用户当前位置经纬度 navigator.geolocation.getCurrentPosition(function(position) { const userLatitude = position.coords.latitude; const userLongitude = position.coords.longitude; // 计算用户当前位置距离中心点的距离 const distance = getDistance(centerLatitude, centerLongitude, userLatitude, userLongitude); // 判断距离是否小于500米 if (distance < 500) { // 距离小于500米,打卡成功 alert("打卡成功!"); } else { // 距离大于500米,打卡失败 alert("距离中心点太远,请靠近中心点后再打卡!"); } }); // 计算两个经纬度之间的距离(单位:米) function getDistance(lat1, lng1, lat2, lng2) { const radLat1 = lat1 * Math.PI / 180.0; const radLat2 = lat2 * Math.PI / 180.0; const a = radLat1 - radLat2; const b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0; const s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2))); const earthRadius = 6378137; // 地球半径,单位:米 return s * earthRadius; } ``` 在这个示例中,我们首先定义了中心点的经纬度。然后,使用浏览器的`getCurrentPosition`方法获取用户当前位置的经纬度,并使用`getDistance`函数计算用户当前位置距离中心点的距离。最后,根据距离判断是否在500米范围内,并显示相应的提示信息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值