微信小程序地图划线

上代码:

[javascript] view plain copy 1.var point = []
2.var that2

  1. 6.function drawline() {
  2. that2.setData({
  3. polyline: [{
  4. points: point,
  5. color: “#99FF00”,
  6. width: 4,
  7. dottedLine: false
  8. }],
  9. })
  10. 21.}
    22.//获取经纬度
    23.function getlocation() {
  11. var latitude1, longitude1
  12. wx.getLocation({
  13. type: ‘gcj02’,
  14. success: function (res) {
  15. latitude1 = res.latitude
  16. longitude1 = res.longitude
  17. point.push({latitude:latitude1, longitude:longitude1})
  18. console.log(point)
  19. }
  20. })
  21. 36.}
  22. 39.Page({
  23. data: {
  24. polyline: []
  25. },
  26. onReady: function () {
  27. that2 = this
  28. wx.getLocation({
  29. type: ‘gcj02’,
  30. success: function (res) {
  31. that2.setData({
  32. long: res.longitude,
  33. lat: res.latitude
  34. })
  35. }
  36. })
  37. },
  38. start:function(){
  39. this.timer=setInterval(repeat, 10000);
  40. function repeat() {
  41. console.log(“re”)
  42. getlocation()
  43. drawline()
  44. }
  45. },
  46. end: function () {
  47. console.log(“clear”)
  48. clearInterval(this.timer)
  49. }
  50. 88.})

打赏一个呗

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦