收藏
回答

在地图组件使用的时候地图无法显示?

下列是相关代码:
var jingdu=null;
var weidu=null;
Page({
  data: {
    jingdu:null,
    weidu:null,
    markers: [{
      iconPath: "/resources/others.png",
      id: 0,
      latitude: null,
      longitude: null,
      width: 50,
      height: 50
    }],
    polyline: [{
      points: [{
        longitude: 113.3245211,
        latitude: 23.10229
      }, {
        longitude: 113.324520,
        latitude: 23.21229
      }],
      color:"#FF0000DD",
      width: 2,
      dottedLine: true
    }],
    controls: [{
      id: 1,
      iconPath: '/resources/location.png',
      position: {
        left: 0,
        top: 300 - 50,
        width: 50,
        height: 50
      },
      clickable: true
    }]
  },
  regionchange(e) {
    console.log(e.type)
  },
  markertap(e) {
    console.log(e.detail.markerId)
  },
  controltap(e) {
    console.log(e.detail.controlId)
  },
  onLoad:function(){
    if (!wx.cloud) {
      wx.redirectTo({
        url: '../chooseLib/chooseLib',
      })
      return
    }


    // 获取用户信息
    wx.getSetting({
      success: res => {
        if (res.authSetting['scope.userInfo']) {
          // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
          wx.getUserInfo({
            success: res => {
              console.log("授权成功 "+res)
              console.log(res)
              wx.getLocation({
                success: res => {
                  console.log(res)
                  this.setData({
                    'markers[0].latitude':'res.latitude',
                    'markers[0].longitude':'res.longitude',
                    jingdu:res.longtitude,
                    weidu:res.latitude
                  })
                  console.log({jigndu})
                  console.log({weidu})
                }
              })
            }
          })
        }
      }
    })
  },
})
wwxml
<map id="map" longitude="{{jingdu}}" latitude="{{weidu}}" scale="14" controls="{{controls}}" bindcontroltap="controltap" markers="{{markers}}" bindmarkertap="markertap" polyline="{{polyline}}" bindregionchange="regionchange" show-location style="width: 100%; height:300px;"></map>
d地图是一片白的,错误我没看懂,说着没定义,但是这个jingdu是在data里面的啊,而且我也定义了var jingdu=null;
z这是错误信息

回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签