您好,欢迎来到纷纭教育。
搜索
您的当前位置:首页uni.getLocation根据经纬度获取地址

uni.getLocation根据经纬度获取地址

来源:纷纭教育

使用uni开发app时需要获取用户位置并返回到后台:

uni.getLocation使用时:type要换成gcj02,success回调中位置,只有app才支持,需要将geocode设为true

uni.getLocation({
	type:'gcj02',
	geocode:true,
	success(res){
		let latitude=res.latitude;
		let longitude=res.longitude;
  letareaname=res.address.province+res.address.city+res.address.district+res.address.street+res.address.streetNum+res.address.poiName
		console.log(areaname)
	}
})

非app时想要获取位置:

var QQMapWX = require('../../libs/qqmap-wx-jssdk.min.js');
var zhuan_dingwei = require('../../libs/dingwei.js');
// 实例化API核心类
var demo = new QQMapWX({
  key: 'JMXBZ-PJ2W3-HP33K-3QRUG-VEXCV-TQBOR'
});
demo.reverseGeocoder({
    location: {
       latitude:res.latitude,
       longitude: res.longitude
     },
    success(res){
    console.log("位置:"+res)
    }
})

 

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- fenyunshixun.cn 版权所有 湘ICP备2023022495号-9

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务