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

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

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

本文實(shí)例為大家分享了微信小程序map地圖使用的具體實(shí)現(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:{
 
    // 點(diǎn)擊標(biāo)記點(diǎn)
   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)記點(diǎn)在地圖可視視野內(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
    })
   },
}

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

相關(guān)文章

最新評(píng)論

澄江县| 海城市| 象州县| 丰原市| 昭苏县| 射阳县| 南投县| 调兵山市| 曲阳县| 洛阳市| 罗城| 丹巴县| 札达县| 漯河市| 阿图什市| 治县。| 皮山县| 旌德县| 瑞金市| 闻喜县| 原平市| 长春市| 峨边| 苍溪县| 西充县| 金门县| 惠州市| 长岭县| 红河县| 衡阳县| 肥城市| 正蓝旗| 高要市| 临澧县| 尼木县| 开化县| 长阳| 庆元县| 青神县| 印江| 香格里拉县|