|
@@ -41,6 +41,8 @@ const popType = [
|
|
|
]
|
|
|
]
|
|
|
|
|
|
+let BMap = {};
|
|
|
+
|
|
|
const INIT_MARKER = {
|
|
|
latitude: 0,
|
|
|
longitude: 0,
|
|
@@ -89,16 +91,9 @@ Page({
|
|
|
|
|
|
onLoad: function () {
|
|
|
var that = this;
|
|
|
- // var BMap = new bmap.BMapWX({
|
|
|
- // ak: 'QCc4aj8erQKVSfREHsbOLEDu3htQrNQU'
|
|
|
- // });
|
|
|
-
|
|
|
- var fail = function (data) {
|
|
|
- console.log(data)
|
|
|
- };
|
|
|
- var success = function (data) {
|
|
|
- wxMarkerData = data.wxMarkerData;
|
|
|
- }
|
|
|
+ BMap = new bmap.BMapWX({
|
|
|
+ ak: 'QCc4aj8erQKVSfREHsbOLEDu3htQrNQU'
|
|
|
+ });
|
|
|
this.setData({
|
|
|
height: wx.getSystemInfoSync().windowHeight
|
|
|
})
|
|
@@ -1271,6 +1266,28 @@ Page({
|
|
|
detail_index: index,
|
|
|
trafficEnd: item.address
|
|
|
});
|
|
|
+ BMap.geocoding({
|
|
|
+ address: item.address,
|
|
|
+ success: function (data) {
|
|
|
+ wxMarkerData = data.wxMarkerData;
|
|
|
+ console.log(wxMarkerData);
|
|
|
+ wxMarkerData.latitude
|
|
|
+ wxMarkerData.longitude
|
|
|
+ that.setData({
|
|
|
+ latitude: wxMarkerData[0].latitude,
|
|
|
+ longitude: wxMarkerData[0].longitude,
|
|
|
+ markers:[{
|
|
|
+ latitude: wxMarkerData[0].latitude,
|
|
|
+ longitude: wxMarkerData[0].longitude,
|
|
|
+ iconPath: imgUrl+"/location.png",
|
|
|
+ width: '34px',
|
|
|
+ height: '34px',
|
|
|
+ rotate: 0,
|
|
|
+ alpha: 1
|
|
|
+ }]
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
getSearchVal(e) {
|
|
|
this.setData({
|
|
@@ -1359,20 +1376,42 @@ Page({
|
|
|
},
|
|
|
|
|
|
backSearch() {
|
|
|
- if (!this.data.isList) {
|
|
|
+ let that =this
|
|
|
+ if (!that.data.isList) {
|
|
|
this.setData({
|
|
|
isList: true,
|
|
|
showSearch: true,
|
|
|
showSet: false
|
|
|
});
|
|
|
} else {
|
|
|
- if (!this.data.showTraffic) {
|
|
|
- this.setData({
|
|
|
+ if (!that.data.showTraffic) {
|
|
|
+ that.setData({
|
|
|
showTraffic: true,
|
|
|
showSearch: true,
|
|
|
searchVal: ''
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
+ wx.getLocation({
|
|
|
+ type: 'gcj02', //返回可以用于wx.openLocation的经纬度
|
|
|
+ success (res) {
|
|
|
+ const latitude = res.latitude
|
|
|
+ const longitude = res.longitude
|
|
|
+ that.setData({
|
|
|
+ latitude: latitude,
|
|
|
+ longitude:longitude,
|
|
|
+ markers:[{
|
|
|
+ latitude: latitude,
|
|
|
+ longitude: longitude,
|
|
|
+ iconPath: imgUrl+"/location.png",
|
|
|
+ width: '34px',
|
|
|
+ height: '34px',
|
|
|
+ rotate: 0,
|
|
|
+ alpha: 1
|
|
|
+ }]
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
}
|
|
|
});
|