微信更新到7.05后map markers不显示,7.03的版本没有问题。求解?
发布于 7 年前 作者 yong13 7312 次浏览 来自 官方Issues

以上开发工具显示正常。真机调试,这个点就显示不了。代码如下:

<map

      id=“map”

      longitude="{{longitude}}"

      latitude="{{latitude}}"

      scale="{{accuracy}}"

      markers="{{showMarkers}}"

      covers="{{covers}}"

      bindmarkertap=“markertap”

      bindcallouttap=“callouttap”

      show-location

      style=“width: 100%; height: {{mapHeight}}rpx;”

    >

      <cover-view class=“map-controls”>

        <cover-view class=“map-reset” bindtap=“mapReset”>

          <cover-image class=“map-img” src=“resources/picture/mapReset.png” />

        </cover-view>

        <cover-view class=“map-nav” bindtap=“mapNavigation”>

          <cover-image class=“map-img” src=“resources/picture/mapNavigation.png” />

        </cover-view>

      </cover-view>

    </map>

//----------------------------index.js-----------------------------------

const config = require("…/…/config.js");

var app = getApp();

Page({

  data: {

    activeIndex: 1// tabs默认选中项

    tasks: [],

    mapHeight: 0, // 地图高度

    latitude: 0,//纬度

    longitude: 0,//经度

    speed: 0,//速度

    accuracy: 14,//位置精准度

    markers: [],

    showMarkers: [],

    selectedMarker: {}

  },

  onReady: function (options) {

    this.mapCtx = wx.createMapContext(‘myMap’)

  },

  onLoad: function (options) {

    this.getLocation()

    let windowHeight = wx.getSystemInfoSync().windowHeight // 屏幕的高度

    let windowWidth = wx.getSystemInfoSync().windowWidth // 屏幕的宽度

    let safeArea = wx.getSystemInfoSync().safeArea

    console.log(safeArea)

    let height = windowHeight * 750 / windowWidth - (44 + 48) * 2

    this.setData({

      mapHeight: height

    })

  },

  onShow() {

    if (typeof this.getTabBar === ‘function’ &&

      this.getTabBar()) {

      this.getTabBar().setData({

        selected: 0

      })

    }

  },

  onShareAppMessage: function (res) {

    return {

      path: ‘/pages/task/index’

    }

  },

  // 点击tabs:列表、地图

  tabsClick(event) {

    let index = event.detail.index

    if (index == 0) {

      wx.removeTabBarBadge({

        index: 0,

      })

    }

  },

  // 选择任务

  taskClick(event) {

    let index = event.currentTarget.dataset.idx

    let task = this.data.tasks[index]

    let imageName = task[“status1”] + “-” + task[“status2”] + “-” + task[“status3”] + “.png”;

    var marker = {

      id: 0,

      latitude: task[“lat”],

      longitude: task[“lon”],

      name: task[“title”],

      desc: task[“desc”],

      label: task[“deviceId”],

      iconPath: ‘/pages/task/resources/picture/status-’ + imageName

    }

    this.setData({

      latitude: marker.latitude,

      longitude: marker.longitude,

      showMarkers: [marker],

      selectedMarker: marker,

      activeIndex: 1

    })

  },

  // 获取定位

  getLocation: function () {

    let that = this

    wx.getLocation({

      type: ‘gcj02’,

      success: function (res) {

        if (app.globalData.loginName.length < 1) {

          return

        }

        var latitude = res.latitude

        var longitude = res.longitude

        var speed = res.speed

        app.globalData.latitude = latitude

        app.globalData.longitude = longitude

        that.setData({

          longitude: longitude,

          latitude: latitude,

          speed: speed

        })

        that.getAroundPoints()

        that.getTasks()

      }

    })

  },

  // 点击标注点

  markertap(e) {

    let markers = this.data.markers

    this.setData({

      selectedMarker: markers[e.markerId]

    })

  },

  // 点击气泡:查看设备详情

  callouttap(e) {

    let marker = this.data.markers[e.markerId]

    console.log(marker)

    wx.navigateTo({

      url: ‘taskDetail/index?deviceId=’ + marker.label,

    })

  },

  // 点击地图重置

  mapReset() {

    let markers = this.data.markers

    this.setData({

      showMarkers: markers

    })

    this.getAroundPoints()

  },

  // 点击地图导航

  mapNavigation() {

    let that = this

    wx.openLocation({

      latitude: that.data.selectedMarker.latitude,

      longitude: that.data.selectedMarker.longitude,

      name: that.data.selectedMarker.name,

      address: that.data.selectedMarker.desc

    })

  },

  // 定位完成后获取周边点位

  getAroundPoints() {

    let that = this

    var params = “?lat=” + app.globalData.latitude + “&radiu=500”

    params = params + “&lon=” + app.globalData.longitude

    params = params + “&loginName=” + app.globalData.loginName

    wx.request({

      url: config.getPointsUrl + params,

      success: function (res) {

        if (!res.data.success) {

          wx.showToast({

            title: res.data.msg,

            icon: “none”,

            duration: 2500

          })

          return

        }

        console.log(res)

        var markers = []

        let points = res.data.points

        for (var i = 0; i < points.length; i++) {

          let point = points[i]

          var marker = {}

          if (point[“taskDevice”]) {

            let imageName = point[“status1”] + “-” + point[“status2”] + “-” + point[“status3”] + “.png”;

            marker = {

              id: i,

              latitude: point[“lat”],

              longitude: point[“lon”],

              name: point[“title”],

              desc: point[“desc”],

              label: point[“deviceId”],

              iconPath: ‘/pages/task/resources/picture/status-’ + imageName

            }

          } else {

              marker = {

              id: i,

              latitude: point[“lat”],

              longitude: point[“lon”],

              name: point[“title”],

              desc: point[“desc”],

              label: point[“deviceId”]

            }

          }

          markers.push(marker)

        }

        console.log(markers)

        that.setData({

          markers: markers,

          showMarkers: markers

        })

      },

      fail: function () {

        wx.showToast({

          title: ‘网络请求失败,请检查网络’,

          icon: “none”,

          duration: 2500

        })

      }

    })

  },

  // 获取任务列表

  getTasks() {

    let that = this

    var params = “?lat=” + app.globalData.latitude

    params = params + “&lon=” + app.globalData.longitude

    params = params + “&loginName=” + app.globalData.loginName

    wx.request({

      url: config.getTasksUrl + params,

      success: function (res) {

        console.log(“任务列表”)

        console.log(res)

        if (!res.data.success) {

          wx.showToast({

            title: res.data.msg,

            icon: “none”,

            duration: 2500

          })

          return

        }

        wx.setTabBarBadge({

          index: 0,

          text: “” + res.data.tasks.length

        })

        that.setData({

          tasks: res.data.tasks,

        })

      },

      fail: function () {

        wx.showToast({

          title: ‘网络请求失败,请检查网络’,

          icon: “none”,

          duration: 2500

        })

      }

    })

  }

})

3 回复

iphone7,微信版本号,7.05,ios12.3.1;代码断见上;安卓系统,微信版本号7.05、7.06都有问题。微信7.03ios/安卓都没有问题。

麻烦提供出现问题的具体机型、微信版本号、系统版本号,以及能复现问题的代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html

请问楼主解决了吗?

回到顶部