地图markers更新时会将地图重置到初始化的位置
211 浏览2022年12月02日作者:Sakura_____________


地图markers更新时会将地图重置到初始化的位置





js:

Page({

  data: {

    markers: [

      {

        iconPath: "https://oss-vehicle-collect.oss-cn-beijing.aliyuncs.com/miniprogram-image/mp-2021-imgs/homepage/marks-icon/common-icon/red_point_n.png",

        longitude: 38.89907,

        latitude: 121.598688,

        id: 99999999,

        width: 100,

        height: 100,

        anchor: { x: .5, y: .5 },

        zIndex: 999

      },

      {

        id: 1,

        longitude: 116.397493,

        latitude: 39.907957,

        title: "这是地标1",

        alpha: 0.6,

        anchorX: 0.5,

        anchorY: 1,

      },

    ]

  },

  onLoad: function (options) {

    console.log(tt.getSystemInfoSync())

    const _this = this;

    console.log()

    setInterval(function () {

      console.log(_this)

      _this.data.markers.push({

        id: 1,

        longitude: 116.397493,

        latitude: 39.907957,

        title: "这是地标1",

        alpha: 0.6,

        anchorX: 0.5,

        anchorY: 1,

      });

      _this.setData({

        markers: _this.data.markers

      })

    }, 3000)

  }

})


ttml:


<view style="width: 100vw;height:100vh;">

    <map style="width: 100%;height:100%;" latitude="121.598688" longitude="38.89907" markers="{{markers}}">

    </map>

</view>

最后一次编辑于 2022 年 12 月 02 日
3 条评论

相关文章

专题推荐

热门文章

热门问答