溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

微信小程序開發(fā)如何實現(xiàn)地圖功能

發(fā)布時間:2022-03-14 10:03:01 來源:億速云 閱讀:865 作者:iii 欄目:開發(fā)技術

這篇文章主要講解了“微信小程序開發(fā)如何實現(xiàn)地圖功能”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“微信小程序開發(fā)如何實現(xiàn)地圖功能”吧!

微信小程序開發(fā)如何實現(xiàn)地圖功能

基本使用

地圖組件使用起來也很簡單。

.wxml

<map id="map" longitude="{{longitude}}" latitude="{{latitude}}" scale="14" controls="{{controls}}" bindcontroltap="controltap" markers="{{markers}}" bindmarkertap="markertap" polyline="{{polyline}}" circles="{{circles}}" bindregionchange="regionchange" show-location >
</map>

除了顯示基本地圖,還可以在地圖上添加markers&ndash;標注,polyline&ndash;折線,circles&ndash;圓形,controls&ndash;控件。

markers

data: {
    //
    markers: [{
      iconPath: "../../img/marker_red.png",
      id: 0,
      latitude: 40.002607,
      longitude: 116.487847,
      width: 35,
      height: 45
    }],
    ... //省略代碼
    }

在data中定義markers變量來表示覆蓋物

然后map控件引入即可:

<map id="map" longitude="{{longitude}}"  markers="{{markers}}"  ...//省略代碼>
</map>

polyline

data: {
    //
    polyline: [{
      points: [{
        longitude: '116.481451',
        latitude: '40.006822'
      }, {
        longitude: '116.487847',
        latitude: '40.002607'
      }, {
        longitude: '116.496507',
        latitude: '40.006103'
      }],
      color: "#FF0000DD",
      width: 3,
      dottedLine: true
    }],
    ... //省略代碼
    }
<map id="map" longitude="{{longitude}}" latitude="{{latitude}}" polyline="{{polyline}}" >

circles

data: {
    //
    circles: [{
      latitude: '40.007153',
      longitude: '116.491081',
      color: '#FF0000DD',
      fillColor: '#7cb5ec88',
      radius: 400,
      strokeWidth: 2
    }],
    ... //省略代碼
    }

感謝各位的閱讀,以上就是“微信小程序開發(fā)如何實現(xiàn)地圖功能”的內容了,經(jīng)過本文的學習后,相信大家對微信小程序開發(fā)如何實現(xiàn)地圖功能這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內容。

AI