1.bmap-wx.min.js
例子链接
2.ak
百度地图平台
ak申请教程
3.getLocation.js
var bmap = require('./bmap-wx.min');
function getLocation(sourceObj, successFun, failFun) {
var BMap = new bmap.BMapWX({
ak: "#",
});
BMap.regeocoding({
success: function (res) {
console.log('BMap',res);
typeof successFun == 'function' && successFun(res, sourceObj);
},
fail: function (res) {
console.log('fail',res);
typeof failFun == 'function' && failFun(res, sourceObj)
},
});
};
module.exports = {
getLocation:getLocation,
}
4.app.js
const getLocation = require('./utils/getNowLocation.js');
App({
getLocation:getLocation,
});
5.xxx.js
const app = getApp();
Page({
data: {
markers: [],
longitude: '',
latitude: '',
address: '',