美文网首页HBuilder开发
【hbuilder】geolocation获取 百度gps定位地

【hbuilder】geolocation获取 百度gps定位地

作者: 老牛圣斗士 | 来源:发表于2016-04-02 16:45 被阅读1136次

    把下面代码包含在js中调用

    mui.plusReady(function()

    {

    plus.geolocation.getCurrentPosition( geoInf, function ( e ) {

    },{geocode:true,provider:'amap'});

    });

    function geoInf( position ) {

    var codns = position.coords;//获取地理坐标信息;

    var longt = codns.longitude;//获取到当前位置的经度

    var lat = codns.latitude;//获取到当前位置的纬度;

    //详细地址获取使用  position.address

    document.getElementById("city").value=position.address.city ;//获取具体市名称

    }

    地址解析如何获取具体的省市县街道信息等:

    相关文章

      网友评论

        本文标题:【hbuilder】geolocation获取 百度gps定位地

        本文链接:https://www.haomeiwen.com/subject/rmaylttx.html