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
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 }})