uin-appmap踩的坑

    技术2024-01-28  93

    1 scale 缩放地图

    无法更改缩放比例,只有在页面一开始加载时才会加载一下,后续更改无效 在小程序上折中一下

    主要是 that.scale = 15; setTimeout(function(){ that.scale = 16; },0) 这样可以更改缩放比例, 只在小程序上测试过,别的端没有 代码:

    // 获取地理位置与经纬度 jingwei(){ uni.hideLoading(); let that = this; uni.chooseLocation({ success: function (res) { that.formData.city.value = res.address; that.latitude = parseFloat(res.latitude) - 0.004; // that.marker[0].latitude = res.latitude; that.longitude = res.longitude; // that.marker[0].longitude = res.longitude; that.successMsg('调用成功') that.scale = 15; setTimeout(function(){ that.scale = 16; },0) console.log(that.scale) }, fail() { that.errorMsg('调用失败') } }); },``

    map 标签里的 cover-view不支持input输入框

    用input浮在cover-view上,能看到光标,利用input focus属性唤起键盘

    贴代码: html

    <cover-view @tap.stop="tapInput(1)" class="jiaodian" :class="!formData.detail.value?'zi-hui':''"> {{formData.detail.value?formData.detail.value:'请填写具体地址'}} <input v-model="formData.detail.value" :focus="inputFocusDetail" class="uni-input" /> </cover-view>

    css

    .jiaodian{ width:calc(100% - 30rpx - 150rpx); height: 60rpx; line-height: 70rpx; position: relative; } .uni-input{ height: 60rpx; line-height: 70rpx; /* margin-top为text的高度,保持视觉上一致 */ margin-top: -60rpx; opacity: 0; color: rgba(255,255,255,0); }

    js

    tapInput() { this.inputFocus = true; }, // 放在最大的盒子上,利用事件冒泡使input失去焦点 shiqu(){ this.inputFocus = false; },

    在map 里怎么使用裁图插件

    因为cover-view不支持view标签,并且map标签层级最高,无法操作,我的解决方法是写两份,一份放在map标签外面,点击里面的按钮或图片调用js 把map隐藏利用放在外面的组件进行裁图,

    后记问题 在h5端重新获取经纬度,在地图上不显示定位的图标,请问是怎么回事,知道的请评论和赐教

    Processed: 0.013, SQL: 9