日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)小程序教程:微信小程序API地圖組件控制

wx.createMapContext(mapId)


創(chuàng)建并返回 map 上下文 mapContext 對象。在自定義組件下,第二個參數(shù)傳入組件實(shí)例this,以操作組件內(nèi)  組件

mapContext

mapContext通過 mapId 跟一個組件綁定,通過它可以操作對應(yīng)的組件。

mapContext 對象的方法列表

方法 參數(shù) 說明 最低版本
getCenterLocationOBJECT獲取當(dāng)前地圖中心的經(jīng)緯度,返回的是 gcj02 坐標(biāo)系,可以用于 wx.openLocation  
moveToLocation將地圖中心移動到當(dāng)前定位點(diǎn),需要配合map組件的show-location使用 
translateMarkerOBJECT平移marker,帶動畫1.2.0
includePointsOBJECT縮放視野展示所有經(jīng)緯度1.2.0
getRegionOBJECT獲取當(dāng)前地圖的視野范圍1.4.0
getScaleOBJECT獲取當(dāng)前地圖的縮放級別1.4.0

getCenterLocation 的 OBJECT 參數(shù)列表

參數(shù) 類型 必填 說明
successFunction接口調(diào)用成功的回調(diào)函數(shù) ,res = { longitude: "經(jīng)度", latitude: "緯度"}
failFunction接口調(diào)用失敗的回調(diào)函數(shù)
completeFunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

translateMarker 的 OBJECT 參數(shù)列表

參數(shù) 類型 必填 說明
markerIdNumber指定marker
destinationObject指定marker移動到的目標(biāo)點(diǎn)
autoRotateBoolean移動過程中是否自動旋轉(zhuǎn)marker
rotateNumbermarker的旋轉(zhuǎn)角度
durationNumber動畫持續(xù)時長,默認(rèn)值1000ms,平移與旋轉(zhuǎn)分別計(jì)算
animationEndFunction動畫結(jié)束回調(diào)函數(shù)
failFunction接口調(diào)用失敗的回調(diào)函數(shù)

includePoints 的 OBJECT 參數(shù)列表

參數(shù) 類型 必填 說明
pointsArray要顯示在可視區(qū)域內(nèi)的坐標(biāo)點(diǎn)列表,[{latitude, longitude}]
paddingArray坐標(biāo)點(diǎn)形成的矩形邊緣到地圖邊緣的距離,單位像素。格式為[上,右,下,左],安卓上只能識別數(shù)組第一項(xiàng),上下左右的padding一致。開發(fā)者工具暫不支持padding參數(shù)。

getRegion 的 OBJECT 參數(shù)列表

參數(shù) 類型 必填 說明
successFunction接口調(diào)用成功的回調(diào)函數(shù),res = {southwest, northeast},西南角與東北角的經(jīng)緯度
failFunction接口調(diào)用失敗的回調(diào)函數(shù)
completeFunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

getScale 的 OBJECT 參數(shù)列表

參數(shù) 類型 必填 說明
successFunction接口調(diào)用成功的回調(diào)函數(shù),res = {scale}
failFunction接口調(diào)用失敗的回調(diào)函數(shù)
completeFunction接口調(diào)用結(jié)束的回調(diào)函數(shù)(調(diào)用成功、失敗都會執(zhí)行)

示例代碼:







// map.js
Page({
  onReady: function (e) {
    // 使用 wx.createMapContext 獲取 map 上下文
    this.mapCtx = wx.createMapContext('myMap')
  },
  getCenterLocation: function () {
    this.mapCtx.getCenterLocation({
      success: function(res){
        console.log(res.longitude)
        console.log(res.latitude)
      }
    })
  },
  moveToLocation: function () {
    this.mapCtx.moveToLocation()
  },
  translateMarker: function() {
    this.mapCtx.translateMarker({
      markerId: 0,
      autoRotate: true,
      duration: 1000,
      destination: {
        latitude:23.10229,
        longitude:113.3345211,
      },
      animationEnd() {
        console.log('animation end')
      }
    })
  },
  includePoints: function() {
    this.mapCtx.includePoints({
      padding: [10],
      points: [{
        latitude:23.10229,
        longitude:113.3345211,
      }, {
        latitude:23.00229,
        longitude:113.3345211,
      }]
    })
  }
})


新聞名稱:創(chuàng)新互聯(lián)小程序教程:微信小程序API地圖組件控制
轉(zhuǎn)載源于:http://www.dlmjj.cn/article/djchjgi.html