|
@@ -40,10 +40,23 @@ const popType = [
|
|
|
[]
|
|
|
]
|
|
|
]
|
|
|
+
|
|
|
+const INIT_MARKER = {
|
|
|
+ latitude: 0,
|
|
|
+ longitude: 0,
|
|
|
+ iconPath: imgUrl+"/location.png",
|
|
|
+ width: '34px',
|
|
|
+ height: '34px',
|
|
|
+ rotate: 0,
|
|
|
+ alpha: 1
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
Page({
|
|
|
data: {
|
|
|
imgUrl: imgUrl,
|
|
|
- markers: [],
|
|
|
+ markers: [INIT_MARKER],
|
|
|
latitude: '',
|
|
|
longitude: '',
|
|
|
type: [
|
|
@@ -75,34 +88,39 @@ Page({
|
|
|
|
|
|
onLoad: function () {
|
|
|
var that = this;
|
|
|
- var BMap = new bmap.BMapWX({
|
|
|
- ak: 'QCc4aj8erQKVSfREHsbOLEDu3htQrNQU'
|
|
|
- });
|
|
|
+ // var BMap = new bmap.BMapWX({
|
|
|
+ // ak: 'QCc4aj8erQKVSfREHsbOLEDu3htQrNQU'
|
|
|
+ // });
|
|
|
|
|
|
var fail = function (data) {
|
|
|
console.log(data)
|
|
|
};
|
|
|
var success = function (data) {
|
|
|
wxMarkerData = data.wxMarkerData;
|
|
|
- that.setData({
|
|
|
- markers: wxMarkerData
|
|
|
- });
|
|
|
- that.setData({
|
|
|
- latitude: wxMarkerData[0].latitude
|
|
|
- });
|
|
|
- that.setData({
|
|
|
- longitude: wxMarkerData[0].longitude
|
|
|
- });
|
|
|
}
|
|
|
this.setData({
|
|
|
height: wx.getSystemInfoSync().windowHeight
|
|
|
})
|
|
|
- BMap.geocoding({
|
|
|
- address: '重庆市',
|
|
|
- fail: fail,
|
|
|
- success: success
|
|
|
- });
|
|
|
-
|
|
|
+ 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
|
|
|
+ }]
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
// 初始化数据
|
|
|
wx.request({
|
|
|
url: 'https://www.cqna.gov.cn/data/mapdata/getMapDataAll',
|