zoukankan      html  css  js  c++  java
  • 微信小程序input框之地图位置显示

    页面效果

    HTML代码

    <view class="mapBlock">
      <view class="lable">项目坐标</view>
      <map
          id="myMap"
          style="{{csstext}}"
          latitude="{{latitude}}"
          longitude="{{longitude}}"
          markers="{{markers}}"
          covers="{{covers}}"
          show-location
        ></map>
    </view>

    CSS代码

    .mapBlock{
      height: 220rpx;
      display: flex;
      padding: 20rpx 30rpx;
      font-size: 14px;
      color: #333;
      background-color: #fff;
      box-sizing: border-box;
    }
    .mapBlock>.lable{
      line-height: 180rpx;
      width: 180rpx;
    }

    JS 代码

      data: {
        latitude:"",
        longitude:"",
        csstext:"",
      },
      onLoad: function (options) {
        const that=this;
        wx.getLocation({
          type: 'gcj02',
          success (res) {
            console.log(res)
            that.setData({
              latitude:res.latitude,
              longitude:res.longitude
            })
          }
        })
        let w=wx.getSystemInfoSync().windowWidth;
        let mapw=w-20-90;
        let css=`${mapw}px;height:180rpx`;
        console.log(mapw,css)
        this.setData({
          csstext:css
        })
      },

     记录一下!!

  • 相关阅读:
    软件工程结课作业
    十三次作业
    十二次作业
    十一次作业
    十次作业
    找回感觉的练习
    CSS背景样式和列表样式
    盒子模型案例应用
    display属性
    margin外边距属性
  • 原文地址:https://www.cnblogs.com/banyuege/p/14458756.html
Copyright © 2011-2022 走看看