uni-app 获取地址位置
<h3>uni.getLocation</h3><p> 获取当前的地理位置、速度。 在微信小程序中,当用户离开应用后,此接口无法调用;当用户点击“显示在聊天顶部”时,此接口可继续调用</p>
<div class="cnblogs_Highlighter">
<pre class="brush:html;gutter:true;">
uni.getLocation({
type: 'wgs84 ',
success: function (res) {
console.log('经度:' + res.longitude);
console.log('纬度:' + res.latitude);
}
});
/*
type {string} 默认值'wgs84'
altitude {Boolean} 返回高度信息(比较鸡肋)
success{Function}成功回调
geocode{Boolean} 返回省市信息(仅APP中有效)
fail {Function}失败回调
complete {Function}返回结果回调 成功/失败都会触发
*/
</pre>
</div>
<p>APP端也可以使用HTML5+模块Geolocation</p>
<div class="cnblogs_Highlighter">
<pre class="brush:html;gutter:true;">plus.geolocation.getCurrentPosition(function(p){
console.log(p);
}, function(e){
alert('Geolocation error: ' + e.message);
});
</pre>
</div>
<p> </p><br><br>
来源:https://www.cnblogs.com/smileZAZ/p/14242520.html
頁:
[1]