当前位置:   article > 正文

uniapp使用uni.chooseLocation()打开地图选择位置_app uni.chooselocation

app uni.chooselocation

使用uni.chooseLocation()打开地址选择位置:
 
Uniapp源码视图进行设置
添加这个属性:"requiredPrivateInfos":["chooseLocation"]

 

  1. </template>
  2. <view class="location_box">
  3. <view class="location_box_icon">
  4. <image src="../../static/weizhi.svg" mode=""></image>
  5. <view style="margin-top: 15px;">
  6. {{current_name}}
  7. </view>
  8. </view>
  9. <view class="current_location" @click="current">
  10. <view style="margin-top: 15px;width: 100%;">
  11. 当前位置
  12. </view>
  13. <image src=" ../../static/shuxin.svg" mode="">
  14. </image>
  15. </view>
  16. </view>
  17. <template>
  18. <script>
  19. export default {
  20. data() {
  21. return {
  22. current_name: '',
  23. }
  24. },
  25. onLoad() {
  26. },
  27. methods: {
  28. current() {
  29. uni.chooseLocation({
  30. success: (res) => {
  31. console.log('位置名称:' + res.name);
  32. console.log('详细地址:' + res.address);
  33. console.log('纬度:' + res.latitude);
  34. console.log('经度:' + res.longitude);
  35. this.current_name = res.name
  36. }
  37. });
  38. }
  39. }
  40. }
  41. </script>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/828841
推荐阅读
相关标签
  

闽ICP备14008679号