收藏
回答

map组件使用多个markers时,最终为什么只显示一个标记?

Page({
  data: {
    latitude:34.484652,
    longitude:113.313364,
    markers:[]
  },


  onLoad:function(options) {
    var that=this;
    wx.getLocation({
      type:"wgs84",
      success: function(res){
        var latitude=res.latitude;
        var longitude=res.longitude;
        console.log("当前位置:",res.latitude,res.longitude);
        that.setData({
              latitude:res.latitude,
              longitude:res.longitude,
              markers:[
                {
                  id:0,
                  latitude:res.latitude,
                  longitude:res.longitude,
                  iconPath:"../../img/busy.png",
                  width:30,
                  height:30,
                  callout:{
                      content:"使用中",
                      color:'black',
                      fontSize:13,
                      borderRadius:5,
                      borderWidth:1,
                      borderColor:'#0000ff',
                      padding:2,
                      display:'ALWAYS'
                  },
                },
                 
                {
                  id:1,
                  latitude:34.484652,
                  longitude:113.313364,
                  iconPath:"../../img/free.png",
                  width:30,
                  height:30,
                  callout:{
                      content:"空闲",
                      color:'red',
                      fontSize:13,
                      borderRadius:5,
                      borderWidth:1,
                      borderColor:'#0000ff',
                      padding:2,
                      display:'ALWAYS'
                  },
              } 
              ]
        })
      },
    })
  },
  onReady:function(){


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

4 个回答

  • 取个乱名字不容易
    取个乱名字不容易
    2022-05-13

    解决了吗?

    2022-05-13
    有用
    回复
  • ㅤ
    2021-08-26

    妈的 ,我问题跟你的一模一样。头炸了

    2021-08-26
    有用
    回复
  • 白楠
    白楠
    2021-05-25

    地图没加载出来?是不是两个标记的经纬度过远?试试相近的

    2021-05-25
    有用
    回复 2
    • 南栀向暖
      南栀向暖
      发表于移动端
      2021-05-25
      两个标记的位置是相近的,把第一个标记的经纬度也换成数值最后也只显示一个标记。
      2021-05-25
      回复
    • ㅤ
      2021-08-26回复南栀向暖
      刚才真机看了一下  疯狂缩小地图吧,经纬度几度的差别,定位在天南海北
      2021-08-26
      回复
  • Cjiang
    Cjiang
    2021-05-24

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2021-05-24
    有用
    回复 9
    • 南栀向暖
      南栀向暖
      发表于移动端
      2021-05-24
      代码在上面 我设置了两个标记点,其中第二个固定经纬度的标记显示不出来,第一个标记能正常显示。
      2021-05-24
      回复
    • 南栀向暖
      南栀向暖
      发表于移动端
      2021-05-24回复南栀向暖
      还有第一个标记我想设置成当前位置,但getLocation的位置也偏差很大
      2021-05-24
      回复
    • Cjiang
      Cjiang
      2021-05-24回复南栀向暖
      wxml 代码也给下
      2021-05-24
      回复
    • 南栀向暖
      南栀向暖
      2021-05-24
      2021-05-24
      回复
    • Cjiang
      Cjiang
      2021-05-26回复南栀向暖
      正常 有两个点。
      2021-05-26
      回复
    查看更多(4)
登录 后发表内容