1、使用uni.chooseLocation获取用户信息

               uni.chooseLocation({
					success: (res) => {
						console.log('位置名称:' + res.name);
						console.log('详细地址:' + res.address);
						console.log('纬度:' + res.latitude);
						console.log('经度:' + res.longitude);
					}
				});

2、运用高德获取用户信息

高德微信开发平台

高德微信的小程序key

下载sdk  sdk下载 

 页面使用

引用sdk

import amap from '@/common/js/amap-wx.130.js';

 用 this.amapPlugin.getRegeo调用位置信息,同时也可以调取到天气信息等

import amap from '../../common/amap-wx.js';  
export default {  
    data() {  
        return {  
            amapPlugin: null,  
            key: '这里填写高德开放平台上申请的key'  
        }  
    },  
    onLoad() {  
        this.amapPlugin = new amap.AMapWX({  
            key: this.key  
        });  
       this.chooseSpot()
    }  
	methods: {
      chooseSpot(){
           this.amapPlugin.getRegeo({
					success: (data) => {
					
					}
				});

     }
    }
}

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐