试过调整data里的x和y的数值 但是效果是加载地图时图片左边和上方会出现白边动画,然后还是一样会默认左上角
movable-view大小大于movable-area的情况下下,定位问题?当movable-view大小大于movable-area的时候,movable-view里是一张地图,然后用定位定了很多坐标点。现在是页面加载后默认显示地图的左上角,怎么才能让页面初始化后定位到某一个点。 现在的效果,页面加载后: [图片] 想要的效果,页面加载后直接跳到某一点或者某一指定位置。 [图片] wxml <view class="section" style="height:100vh"> <movable-area style="width:100%;height:100vh;pointer-events:none;"> <movable-view style="width:{{mapWidth}};height:{{mapHeight}};pointer-events:auto;" x="{{x}}" y="{{y}}" direction="all" animation="false"> <image class='img' bindload="imgOnLoad" src="{{imgSrc}}"></image> <view wx:for="{{locations}}" id="{{item.id}}"> <mp-icon data-item="{{item}}" style="position:absolute;left:{{item.left}};top:{{item.top}};" bindtap="itemtap" type="field" icon="location" color="{{item.color}}" size="{{35}}"> </mp-icon> </view> </movable-view> </movable-area> </view> wxss .img{ width: 100%; height: 100%; clear:both; display: block; } movable-view { pointer-events: auto; } movable-area { pointer-events: none; } js //guide.js //获取应用实例 const app = getApp() Page({ data: { x: 0, y: 0, imgSrc:'', mapWidth:'', mapHeight:'' }, onLoad: function (e) { var that=this; wx.showLoading({ title: '加载中......' }); this.setData({ imgSrc:app.globalData.appBean.map1.map_bg, mapWidth:app.globalData.appBean.map1.width, mapHeight:app.globalData.appBean.map1.height, }); }, imgOnLoad(ev) { wx.hideLoading(); } //用户点击右上角分享 onShareAppMessage: function () { return{ title:"云游校园", path:"/pages/guide/guide", } }, })
2020-04-23