当前位置:网站首页>Use and arrangement of wechat applet coordinate position interface (I)

Use and arrangement of wechat applet coordinate position interface (I)

2022-06-13 02:55:00 Tianma 3798

Use and arrangement of coordinate position interface of wechat applet

Common location scenarios :
1. Get current location coordinate
2. Check the location 、 Navigation
3. Select location 、 coordinate
4. analysis / Inverse analysis   Location 《=》 coordinate
5. Route planning
 

One 、 Get current location ,wx.getLocation()

official API:wx.getLocation(Object object) | Wechat open documents

Support applet mobile terminal ,windows Computer terminal ,mac Computer terminal .

Use cases :

     // Get current location 
    wx.getLocation({
      success: res => {
        console.info(res);
      },
      fail: res => {
        console.error(res);
      }
    })

  In particular : The location in the applet needs to be authorized by the user , It is required to use the instructions in the configuration general settings .

app.json The configuration is as follows : The description can be modified by itself

  "permission": {
    "scope.userLocation": {
      "desc": " Your location information will be used to show the effect of the applet location interface " 
    }
  }

Two 、wx.openLocation(Object object) Map open position navigation

Official website API:wx.openLocation(Object object) | Wechat open documents

Support applet mobile terminal ,Mac Computer terminal

    // Get current location 
    wx.getLocation({
      success: res => {
        console.info(res);
        // Open position 
        wx.openLocation({
          latitude: res.latitude,
          longitude: res.longitude,
          name: ' Stephen ',
          address: '12341234'
        })
      },
      fail: res => {
        console.error(res);
      }
    })

3、 ... and 、wx.chooseLocation(Object object) Select location , Select Business District

official API:wx.chooseLocation(Object object) | Wechat open documents

Only the mobile side of the applet is supported

    wx.chooseLocation({
      latitude: 0,
      success:res=>{
        console.info(res);
      }
    })

 

Other interfaces are being improved  

more :

  Wechat applet switch Style rewriting

  Applet Image Component long press to identify supported codes

原网站

版权声明
本文为[Tianma 3798]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202280535329099.html