WeChat Applet -- location API, -- locationapi

Source: Internet
Author: User

Applet -- location API, -- locationapi
The location API can be divided into two types: wx. getLocation (object) to obtain the current location and wx. openLocation (object) to open the built-in map through the longitude and latitude. The parameter returned when locating and obtaining location information is incorrect. The two parameters are unavailable. Another problem is that a Page route error-WAService is returned after the built-in map is opened. js: 2 navigateBack: a nonexistent webviewId0) if you know, I will add a solution to it!

Main attributes:

Wx. getLocation (object) Get the current location

  • Return parameters after successful

Wx. openLocation (object) Open the built-in Map

The built-in application is directly entered here. When the navigation return key is used, the internal writing cannot be intervened.WAService. js: 2 navigateBack a nonexistent webviewId0It is estimated that this error will be fixed by a small program !!

Wxml

<Button id = "0" type = "primary" bindtap = "listenerBtnGetLocation"> locate the current location and open the built-in Location

Js

Page ({data: {text: "Page location"}, onLoad: function (options) {// parameters brought about by Page initialization options }, /*** the listener locates at the current location */listenerBtnGetLocation: function () {wx. getLocation ({// positioning type wgs84, gcj02 type: 'gcj02', success: function (res) {console. log (res) wx. openLocation ({// current latitude and longitude: res. latutude, longpolling: res. longpolling, // default scaling level: 28 scale: 28, // location name: 'test address', // detailed address: '24 Mars Road ', // successfully print the success: function (res) {console. log (res)}, // failure print information fail: function (err) {console. log (err)}, // print the information complete: function (info) {console. log (info) },}, fail: function (err) {console. log (err)}, complete: function (info) {console. log (info) },}, onReady: function () {// page rendering completed}, onShow: function () {// page display}, onHide: function () {// page hiding}, onUnload: function () {// page closing }})

  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.