真机中无法用按钮改变Map组件的缩放比例
发布于 5 年前 作者 osun 11791 次浏览 来自 问答

以下是Demo中的截取的代码。使用IDE能通过按钮缩放比例,但在真机中整个页面都挂掉了。

测试机iphone7(iOS11.0.3 微信6.5.18 基础库1.6.0)

<map

    id=“map”

    longitude="{{longitude}}"

    latitude="{{latitude}}"

    scale="{{scale}}"

    bindregionchange=“bindRegionChange”

    bindcallouttap=‘bindCalloutTap’

    bindupdated=‘bindUpdated’

    show-location>

</map>

<button bindtap=‘bindScaleZoomOut’>缩小</button>

<button bindtap=‘bindScaleZoomIn’>放大</button>

var map = wx.createMapContext(‘map’);

function round(num,d) {

  return (parseFloat(num) * Math.pow(10,d) | 0) / Math.pow(10,d);

}

Page({

  data: {

    longitude: 113.324520,

    latitude: 23.099964,

    scale: 14.0

  },

  bindControlTap(e) {

    return;

  },

  bindScaleZoomOut() {

    this.setData({

      scale: this.data.scale + 1

    });

  },

  bindScaleZoomIn() {

    this.setData({

      scale: this.data.scale - 1

    });

  }

});

回到顶部