Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Mini Program to see the location

2025-02-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to see the location with Mini Program". In the daily operation, I believe many people have doubts about how to use Mini Program to see the location. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to see the location with Mini Program"! Next, please follow the editor to study!

Wx.getLocation (OBJECT)

Get the current geographic location and speed. This API cannot be called when the user leaves Mini Program; when the user clicks "Show at the top of chat", the API can continue to be called.

OBJECT parameter description:

Required parameter type indicates whether typeString returns gps coordinates by default, while gcj02 returns the coordinates available for wx.openLocation. SuccessFunction is a callback function successfully called by the API. For more information, please see the returned parameters. FailFunction No API calls failed callback function completeFunction No API calls the finished callback function (both successful and failed calls will be executed)

Success return parameter description:

Parameter description minimum version latitude latitude, floating point number, range is-90mm 90, negative number indicates south latitude longitude longitude, floating point number, range is-180mm 180. negative number indicates west longitude speed speed, floating point number, accuracy altitude height of unit m/saccuracy position, unit m1.2.0verticalAccuracy vertical precision, unit m (Android cannot be obtained, returns 0) 1.2.0horizontalAccuracy horizontal precision, unit m1.2.0

Sample code:

Wx.getLocation ({type: 'wgs84', success: function (res) {var latitude = res.latitude var longitude = res.longitude var speed = res.speed var accuracy = res.accuracy}}) wx.chooseLocation (OBJECT)

Open the map and select the location.

User authorization scope.userLocation is required

OBJECT parameter description:

The parameter type is required to indicate that successFunction is a callback function successfully called by the API. For more information, please see the returned parameters. FailFunction No API calls failed callback function completeFunction No API calls the finished callback function (both successful and failed calls will be executed)

Success return parameter description:

Parameter description name location name address detailed address latitude latitude, floating point number, range is-90mm 90, negative number indicates south latitude longitude longitude, floating point number, range is-180mm 180, negative number indicates west longitude wx.openLocation (OBJECT)

Use Wechat built-in map to view location.

User authorization scope.userLocation is required

OBJECT parameter description:

The parameter type is required to indicate that latitudeFloat is latitude, with a range of-90mm 90. A negative number indicates that south latitude longitudeFloat is longitude, with a range of-180cm. A negative number indicates the negative scaling ratio of west longitude scaleINT, with a range of 5mm 18. The default is 18nameString negative name addressString No address. Details of successFunction No API call successful callback function failFunction No API call failed callback function completeFunction No API call end callback function (successful or failed will be executed)

Sample code:

Wx.getLocation ({type: 'gcj02', / / returns latitude and longitude success: function (res) {var latitude = res.latitude var longitude = res.longitude wx.openLocation ({latitude: latitude, longitude: longitude, scale: 28})}) Bug & Tip

Bug: iOS 6.3.30 type parameter does not take effect, only coordinate information of wgs84 type is returned

At this point, the study of "how to see the position with Mini Program" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report