地图组件在使用polyline或者polygons时候,总是默认一个位于非洲附近的位置,改不掉
发布于 3 年前 作者 guna 9309 次浏览 来自 官方Issues

先实现点击增加多边形的端点或者在地图上画线,但每次增加第一个点的时候,总是会默认连接到非洲旁边

Page({
  data: {
    polyline: [{
      points: [{
          longitude:null ,
          latitudenull
        },
        {
          longitude:null,
          latitude:null
        },
        {
          longitude:null,
          latitude:null
        },
        {
          longitude:null,
          latitude:null
        },
        
      ],
      color"#000000",
      width3,
      dottedLinefalse
    }]
  },
  change1:function(){
      // 修改起点
      var temp = {
        longitude113.44577861,
        latitude24.48205260
      };
      this.setData({
        'polyline[0].points[0]': temp
      })
  },
  change2:function(){
    // 修改起点
    var temp = {
      longitude:129.44577861,
      latitude60.48205260
    };
    this.setData({
      'polyline[0].points[1]': temp
    })
},
change3:function(){
  // 修改起点
  var temp = {
    longitude100.44577861,
    latitude20.48205260
  };
  this.setData({
    'polyline[0].points[2]': temp
  })
},
change4:function(){
  var temp = {
    longitude113.44577861,
    latitude23.48205260
  };
  this.setData({
    'polyline[0].points[2]': temp
  })
}
})

wxml:
<map id="mapp" latitude="37.488" longitude="121.4499" scale="4" 
   show-compass="true"show-scale="true"   
   polyline="{{polyline}}" style="width:100%;height:750rpx">
</map>
<button bindtap="change1">修改第1个点</button>
<button bindtap="change2">修改第2个点</button>
<button bindtap="change3">修改第3个点</button>
<button bindtap="change4">修改第4个点</button>

2 回复

看下是不是没有拿到经纬度,起始坐标需要赋值

听说过 朱一旦吗?

回到顶部