Quantcast
Channel: CSDN博客移动开发推荐文章
Viewing all articles
Browse latest Browse all 5930

HBuilder webApp开发(十六)定位geolocation

$
0
0

HBuilder的geolocation定位模块其实接口很少,通常我们使用定位模块即可。
这里写图片描述

var posi = null;
mui.plusReady(function() {
    posi = plus.geolocation.getCurrentPosition( function ( p ) {
        console.log( "Geolocation\nLatitude:" + p.coords.latitude + "\nLongitude:" + p.coords.longitude + "\nAltitude:" + p.coords.altitude );
        console.log("street = " + p.address.street);
        console.log("poiName = " + p.address.poiName);
        console.log("coordsType = " + p.coordsType);
        console.log("timestamp = " + p.timestamp);
        console.log("addresses = " + p.addresses);
    }, function ( e ) {
        console.log( "Geolocation error: " + e.message );
    },{enableHighAccuracy: true}); 
});
mui.back = function(){
    var btn = ["确定","取消"];
    mui.confirm('确认关闭当前窗口?','Hello MUI',btn,function(e){
        if(e.index==0){
            // 关闭位置监听  并返回
            plus.geolocation.clearWatch( posi );
            mui.currentWebview.close();
        }
    });
}
作者:zhuming3834 发表于2017/6/13 15:42:51 原文链接
阅读:44 评论:0 查看评论

Viewing all articles
Browse latest Browse all 5930

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>