老司机三级_天天干天天操天天爽_女人被爽到娇喘呻吟视频_久久国产精品99久久久大便 - 亚洲日本系列

位置信息API

本文編輯: JeremyLu JeremyLu瀏覽 4604 版權所有,嚴禁轉載

接口說明:

wx.createMapContext(mapId)

創建并返回 map 上下文 mapContext 對象,通過 mapId 跟一個 組件綁定,通過它可以操作對應的 組件。

方法 說明
getCenterLocation 獲取當前地圖中心的經緯度,返回的是 gcj02 坐標系,可以用于 wx.openLocation
moveToLocation 將地圖中心移動到當前定位點,需要配合map組件的show-location使用

接口用法:


wxml

<view class="container">
  <map id="map" longitude="{{longitude}}" latitude="{{latitude}}" show-location scale="12" style="width: 100%; height: 300px;"></map>
  <button bindtap="getCenterPoint">獲取地圖中心點</button>

  <text>中心點經度:{{longitude}}</text>
  <text>中心點緯度:{{latitude}}</text>

  <button bindtap="setCenterPoint">移動到當前位置</button>
</view>

js

//index.js
//獲取應用實例
var app = getApp()
Page({
  data: {
    latitude: 30.4919168,
    longitude: 114.3061654
  },
  onReady: function(e){
    //關聯<map />組件
    this.mapCtx = wx.createMapContext('map')
  },
  //獲取地圖中心點
  getCenterPoint: function(e){
    var $this = this;
    this.mapCtx.getCenterLocation({
      success: function(res){
        $this.setData({
          latitude: res.latitude,
          longitude: res.longitude
        })
      }
    })
  },
  //將地圖中心點移動到當前位置
  setCenterPoint: function(e){
     this.mapCtx.moveToLocation()
  }
})
如有技術問題或對本文有反饋,請加入QQ群:
微信小程序實戰5營: 微信小程序Club實戰5營