收藏
回答

多个markers如何实现,我写的没效果呀,只能显示一个

问题模块
API和组件

markers: [{

iconPath: "../../img/bike.png",

id: 0,

latitude: 32.02984542637893,

longitude: 120.87840606613159,

width: 24,

height: 34

},

{

iconPath: "../../img/bike.png",

id: 1,

latitude: 32.02984542637123,

longitude: 120.87840606613122,

width: 24,

height: 34

}]


最后一次编辑于  2017-12-14  (未经腾讯允许,不得转载)
回答关注问题邀请回答
收藏

8 个回答

  • YuHua
    YuHua
    2017-12-18

    代码应该是没什么问题,markers我就setDate过一次

    2017-12-18
    赞同
    回复
  • GaleLiu
    GaleLiu
    2017-12-18

    你找找是不是还有什么地方setData了那个markers。或者你在wxml显示一下那个markers是不是正确的

    2017-12-18
    赞同
    回复
  • YuHua
    YuHua
    2017-12-18

    markers_new = [{

    iconPath: "../../img/bike.png",

    id: 0,

    latitude: 23.15239951121,

    longitude: 113.36770856218,

    width: 24,

    height: 34

    },

    {

    iconPath: "../../img/bike.png",

    id: 1,

    latitude: 23.15319565481,

    longitude: 113.368644799478,

    width: 24,

    height: 34

    }];

    that.setData({

    markers: markers_new

    })


    这两个位置还是只显示一个图标呢

    2017-12-18
    赞同
    回复
  • GaleLiu
    GaleLiu
    2017-12-18

    我看了你的那个位置,真的重叠了。给你两经纬度

    la:23.15239951121;long:113.36770856218

    la:23.15319565481; long:113.368644799478

    你测一下这两个位置

    2017-12-18
    赞同
    回复
  • YuHua
    YuHua
    2017-12-18

    <map class='map_w' id="myMap" markers="{{markers}}" style='height:{{screenHeight}}px;' controls="{{controls}}" longitude='109.518198' latitude='18.257981' bindregionchange="regionchange" show-location>

    </map>


    markers_new = [{

    iconPath: "../../img/bike.png",

    id: 0,

    latitude: 32.02984542637893,

    longitude: 120.87840606613159,

    width: 24,

    height: 34

    },

    {

    iconPath: "../../img/bike.png",

    id: 1,

    latitude: 32.02984542123123,

    longitude: 120.87840606123123,

    width: 24,

    height: 34

    }];

    that.setData({

    markers: markers_new

    })




    2017-12-18
    赞同
    回复
  • GaleLiu
    GaleLiu
    2017-12-18

    你贴个map组件和marker的js  代码图片出来看看

    2017-12-18
    赞同
    回复
  • YuHua
    YuHua
    2017-12-18

    还是不行 呀~~~~~~~~~~~~~~

    2017-12-18
    赞同
    回复
  • GaleLiu
    GaleLiu
    2017-12-15

    你试试经纬度相距远一点,估计是重叠了

    2017-12-15
    赞同
    回复