最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序map地圖使用方法詳解

 更新時間:2021年10月12日 10:38:54   作者:熱愛°可抵歲月漫長  
這篇文章主要為大家詳細介紹了微信小程序map地圖使用的方法,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了微信小程序map地圖使用的具體實現(xiàn)代碼,供大家參考,具體內(nèi)容如下

以下代碼是主要的代碼片段

<!-- 地圖部分 -->
  <!-- enable-traffic 顯示路況 -->
  <view class="map_container">
   <map id='customerMap' class="map" :longitude='longitude' :latitude='latitude' :scale='scale'
    :markers='markers' :controls="controls" show-location
    @markertap="markertap" @updated="updatedmap" @controltap='bindcontroltap'></map>
</view>
data(){
  return{
      latitude:23.140962248,
      longitude:113.305301124,
      scale:12,
      markers:[     {id: '',
     latitude: 23.140962248,
     longitude: 113.305301124,
     iconPath: '../static/select-dw.png',//當(dāng)前位置圖標(biāo)路徑
     width: 25,
     height: 39,
     },
                    {
                    latitude: 23.129742,
     longitude: 113.26754,
     iconPath: '../static/mark.png',//客戶圖標(biāo)路徑
     width: 28,
     height: 28,
     label: {
      content: '詹俊俊',
      textAlign: 'center',
      fontSize: 12
        }
                    }]  
 
  }
 
},
onReady() {
 this.mapCtx = wx.createMapContext('customerMap')
},
methods:{
 
    // 點擊標(biāo)記點
   markertap(e) {
    let { markerId } = e.detail;
    let item = this.markers.find(v => v.id === markerId);
    console.log('item', item)
    uni.openLocation({
     latitude: Number(item.latitude),
     longitude: Number(item.longitude),
     name: item.label.content,
     address: item.address,
     success: function() {
      console.log('success');
     }
    });
   },
    // 當(dāng)?shù)貓D加載完成后觸發(fā)
   updatedmap() {
    this.mapUpdated = true;
    console.log('執(zhí)行')
    this.includePoints(); //所有客戶顯示在視圖內(nèi)
   },
    // 讓標(biāo)記點在地圖可視視野內(nèi)
   includePoints() {
    const that = this
    const points = [{
     latitude: that.latitude,
     longitude: that.longitude
    }];
    this.markers.forEach(item => {
     const obi = {
      latitude: item.latitude,
      longitude: item.longitude
     }
     points.push(obi)
    })
    this.mapCtx.includePoints({
     padding: [80, 50, 80, 50],
     points
    })
   },
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

浦东新区| 高安市| 九江县| 鹤山市| 增城市| 陕西省| 鄂温| 宣化县| 砚山县| 仁寿县| 武夷山市| 呼和浩特市| 绵竹市| 平遥县| 冷水江市| 衡水市| 上思县| 龙山县| 镇远县| 三原县| 西盟| 临汾市| 高阳县| 保亭| 故城县| 镇康县| 舟山市| 济南市| 博爱县| 抚远县| 武定县| 措勤县| 南华县| 高尔夫| 武陟县| 甘肃省| 汶上县| 惠东县| 衡东县| 广汉市| 开阳县|