微信开放社区
服务商入驻
文档
登录
切换主页

暂无个人介绍

关注私信

正在关注

0

关注者

0

获得过 0 次赞
回答过的问题获得 0 次赞
分享过的文章/案例获得 0 次赞
评论与回复获得 0 次赞
文章 回答 提问 收藏 关注问题
  • 页面每隔5秒调用JS-SDK中的wx.getLocation方法,为什么每次获取的经纬度是相同的?

    设置每隔5秒调用一次wx.getLocation(),真机上使用vConsole查看时发现输出的经纬度都是一样的,代码如下 setInterval(function () { //每5秒刷新一次图表 //需要执行的代码写在这里 wx.getLocation({ type: 'gcj02', // 默认为wgs84的gps坐标,如果要返回直接给openLocation用的火星坐标,可传入'gcj02' success: function (res) { var latitude = res.latitude; // 纬度,浮点数,范围为90 ~ -90 var longitude = res.longitude; // 经度,浮点数,范围为180 ~ -180。 var speed = res.speed; // 速度,以米/每秒计 var accuracy = res.accuracy; // 位置精度 map.setCenter([longitude, latitude]); var marker = new AMap.Marker({ icon: "https://webapi.amap.com/theme/v1.3/markers/n/mark_b.png", position: [longitude, latitude], anchor:'bottom-center' }); console.log("当前坐标:"+latitude+"-"+longitude); map.add(marker); } }); }, 5000);

    2022-01-19
    2收藏2评论4067浏览
关闭

选择需要上架的开放服务

  • 模板开发

    针对行业、场景的小程序代开发服务,帮助企业快速搭建小程序

    上架
  • 插件

    提供可被小程序直接使用、丰富小程序能力的功能模块

    上架
  • 小商店服务

    为小商店商家提供更多的能力,帮助商家经营好小商店

    上架
关闭

案例类型

  • 小程序
  • 插件
  • 关于腾讯
  • 运营规范
  • 文档中心
  • 辟谣中心
  • 客服中心
  • Copyright © 2012-2025 Tencent. All Rights Reserved.