微信小程序JavaScriptSDK核心类---经纬度转换地址

1.申请开发者密钥(key):http://lbs.qq.com/key.html

2.下载微信小程序JavaScriptSDK :http://3gimg.qq.com/lightmap/xcx/jssdk/qqmap-wx-jssdk1.0.zip

3.安全域名设置,需要在微信公众平台添加域名地址https://apis.map.qq.com

4. 小程序示例       (微信小程序JavaScript SDK :http://lbs.qq.com/qqmap_wx_jssdk/method-search.html

var QQMapWX = require('xxx/qqmap-wx.js');

var demo = new QQMapWX({
    
        key: '开发密钥(key)' // 必填
});
//关键词输入提示
demo.getSuggestion({

    keyword: '电影院',

    success: function(res) {

        console.log(res);

    },

    fail: function(res) {

        console.log(res);

    },

    complete: function(res) {

        console.log(res);

    }

});         

//逆地址解析(坐标位置描述)
demo.reverseGeocoder({

    location: {

        latitude: 39.984060,

        longitude: 116.307520

    },

    success: function(res) {

        console.log(res);

    },

    fail: function(res) {

        console.log(res);

    },

    complete: function(res) {

        console.log(res);

    }

});
 //地址解析(地址转坐标)      

demo.geocoder({

    address: '北京市海淀区彩和坊路海淀西大街74号',

    success: function(res) {

        console.log(res);

    },

    fail: function(res) {

        console.log(res);

    },

    complete: function(res) {

        console.log(res);

    }

});   

//距离计算
demo.calculateDistance({

    to:[{

        latitude: 39.984060,

        longitude: 116.307520

    }, {

        latitude: 39.984572,

        longitude: 116.306339

    }],

    success: function(res) {

        console.log(res);

    },

    fail: function(res) {
        console.log(res);

    },

    complete: function(res) {

        console.log(res);

    }

});      

//获取城市列表

demo.getCityList({
    success: function(res) {
        console.log(res);
    },
    fail: function(res) {
        console.log(res);
    },
    complete: function(res) {
        console.log(res);
    }
});

//获取城市区县


demo.getDistrictByCityId({

    id: '110000', // 对应城市ID

    success: function(res) {

        console.log(res);

    },

    fail: function(res) {

        console.log(res);

    },

    complete: function(res) {

        console.log(res);

    }

});           


                    

 

posted @ 2017-11-14 15:31  ........lhh  阅读(3856)  评论(0编辑  收藏  举报