当前位置:网站首页>JS get the current time, month, day, year, and the uniapp location applet opens the map to select the location
JS get the current time, month, day, year, and the uniapp location applet opens the map to select the location
2022-07-07 14:15:00 【Code s Beethoven's note】
var datetime = new Date();
var year = datetime.getFullYear();
var month = datetime.getMonth() + 1 < 10 ? "0" + (datetime.getMonth() + 1) : datetime.getMonth() + 1;
var date = datetime.getDate() < 10 ? "0" + datetime.getDate() : datetime.getDate();
this.kaishiriqi = year + "-" + month + "-" + date;
Output 2022-07-06uni.getLocation(OBJECT)
Get current geographic location 、 Speed .
OBJECT Parameter description
| Parameter name | type | Required | explain | Platform difference description |
|---|---|---|---|---|
| type | String | no | The default is wgs84 return gps coordinate ,gcj02 Return to the coordinates of the State Bureau of Surveying and mapping , Can be used for uni.openLocation and map Component coordinates ,App and H5 Positioning needs to be configured SDK Information can support gcj02. | |
| altitude | Boolean | no | Pass in true Will return altitude information , Because of the high accuracy required to obtain the height , Will slow down the interface return speed | Bytedance applet 、 Flying Book applet 、 Alipay applet does not support |
| geocode | Boolean | no | Default false, Whether to resolve address information | only App Platform support ( Andrew needs to specify type by gcj02 And configure three-way positioning SDK) |
| highAccuracyExpireTime | Number | no | High precision positioning timeout (ms), Returns the highest precision within the specified time , This value 3000ms The above high-precision positioning is effective | App (3.2.11+)、H5 (3.2.11+)、 Wechat applet ( Base library 2.9.0+) |
| timeout | String | no | The default is 5, Positioning timeout , Unit second | Only flybook applet support |
| cacheTimeout | Number | no | Locate cache timeout , Unit second ; Cache the current location data for each location , And make a time stamp , When the next call is in cacheTimeout Endochronic , Return cached data | Only fly Book applet 、 Alipay applet support |
| accuracy | String | no | The default is high, Specify the desired precision , Support high,best. When specifying high when , The expected accuracy value is 100m, When specifying best The expected precision value is 20m. When the accuracy obtained by positioning does not meet the conditions , stay timeout We will continue to locate before , Try to get the positioning results that meet the requirements | Only flybook applet support |
| isHighAccuracy | Boolean | no | Turn on high-precision positioning | App (3.4.0+)、H5 (3.4.0+)、 Wechat applet ( Base library 2.9.0+) |
| success | Function | yes | Interface calls the successful callback function , Please refer to the return parameter description for the return content . | |
| fail | Function | no | Interface call failed callback function | |
| complete | Function | no | The callback function at the end of the interface call ( Successful call 、 Failure will be carried out ) |
success Return parameter description
| Parameters | explain |
|---|---|
| latitude | latitude , Floating point numbers , The scope is -90~90, A negative number means south latitude |
| longitude | longitude , Floating point numbers , The scope is -180~180, A negative number means the west longitude |
| speed | Speed , Floating point numbers , Company m/s |
| accuracy | The accuracy of the position |
| altitude | Height , Company m |
| verticalAccuracy | Vertical accuracy , Company m(Android Can't get , return 0) |
| horizontalAccuracy | Horizontal accuracy , Company m |
| address | Address information ( only App Client support , Need to configure geocode by true) |
address Address information description
| attribute | type | describe | explain |
|---|---|---|---|
| country | String | Country | Such as “ China ”, If this information cannot be obtained, return undefined |
| province | String | Name of province | Such as “ The Beijing municipal ”, If this information cannot be obtained, return undefined |
| city | String | The city name | Such as “ The Beijing municipal ”, If this information cannot be obtained, return undefined |
| district | String | District ( county ) name | Such as “ Chaoyang District ”, If this information cannot be obtained, return undefined |
| street | String | Street information | Such as “ Jiuxianqiao Road ”, If this information cannot be obtained, return undefined |
| streetNum | String | Get street number information | Such as “3 Number ”, If this information cannot be obtained, return undefined |
| poiName | String | POI Information | Such as “ Electronic City . International Electronics headquarters ”, If this information cannot be obtained, return undefined |
| postalCode | String | Postal Code | Such as “100016”, If this information cannot be obtained, return undefined |
| cityCode | String | City Code | Such as “010”, If this information cannot be obtained, return undefined |
Example
uni.chooseLocation(OBJECT)
Open map to select location .
Platform difference description
| App | H5 | Wechat applet | Alipay applet | Baidu applet | Bytedance applet 、 Flying Book applet | QQ Applet | Kwai Mini program | Jingdong applet |
|---|---|---|---|---|---|---|---|---|
| √ | √ | √ | √ | √ | √ | √ | x | x |
OBJECT Parameter description
| Parameter name | type | Required | explain | Platform difference description |
|---|---|---|---|---|
| latitude | Number | no | Latitude of destination | Wechat applet (2.9.0+)、H5-Vue3(3.2.10+) |
| longitude | Number | no | The longitude of the target | Wechat applet (2.9.0+)、H5-Vue3(3.2.10+) |
| keyword | String | no | Search for keywords , only App Platform support | |
| success | Function | yes | Interface calls the successful callback function , Please refer to the return parameter description for the return content . | |
| fail | Function | no | Interface call failed callback function ( Failed to get location 、 Trigger when the user cancels ) | |
| complete | Function | no | The callback function at the end of the interface call ( Successful call 、 Failure will be carried out ) |
Be careful
- Due to platform differences , If SDK Configure Baidu map , Need to set up keyword, To display the relevant location
nvueSupport Gaode map and Google Map (3.4+), Baidu maps are not supportedHBuilderX 2.4.0+Not weex Compilation mode only supports Gaode map
success Return parameter description
| Parameters | explain |
|---|---|
| name | Location name |
| address | Detailed address |
| latitude | latitude , Floating point numbers , The scope is -90~90, A negative number means south latitude , Use gcj02 National Survey Bureau coordinate system . |
| longitude | longitude , Floating point numbers , The scope is -180~180, A negative number means the west longitude , Use gcj02 National Survey Bureau coordinate system . |
Example

边栏推荐
- Reverse non return to zero code, Manchester code and differential Manchester code of common digital signal coding
- Parameter keywords final, flags, internal, mapping keywords internal
- libSGM的horizontal_path_aggregation程序解读
- 648. Word replacement: the classic application of dictionary tree
- 杭电oj2054 A == B ? ???
- 用例图
- Laravel Form-builder使用
- ES日志报错赏析-Limit of total fields
- AI人才培育新思路,这场直播有你关心的
- 2022-7-6 sigurg is used to receive external data. I don't know why it can't be printed out
猜你喜欢

Vscode configuration uses pylint syntax checker

Vmware共享主机的有线网络IP地址

Vmware 与主机之间传输文件

数据流图,数据字典

Flask session forged hctf admin

使用day.js让时间 (显示为几分钟前 几小时前 几天前 几个月前 )

Evolution of customer service hotline of dewu

Codes de non - retour à zéro inversés, codes Manchester et codes Manchester différentiels couramment utilisés pour le codage des signaux numériques

XML文件的解析操作

Hands on Teaching: XML modeling
随机推荐
Excerpt from "misogyny: female disgust in Japan"
mysql ”Invalid use of null value“ 解决方法
libSGM的horizontal_path_aggregation程序解读
Excuse me, when using Flink SQL sink data to Kafka, the execution is successful, but there is no number in Kafka
Excuse me, as shown in the figure, the python cloud function prompt uses the pymysql module. What's the matter?
2022-7-7 Leetcode 34. Find the first and last positions of elements in a sorted array
Es log error appreciation -limit of total fields
属性关键字Aliases,Calculated,Cardinality,ClientName
UML 顺序图(时序图)
股票开户首选,炒股交易开户佣金最低网上开户安全吗
Details of redis core data structure & new features of redis 6
Laravel5 call to undefined function OpenSSL cipher IV length() error php7 failed to open OpenSSL extension
Battle Atlas: 12 scenarios detailing the requirements for container safety construction
杭电oj2092 整数解
Flask session forged hctf admin
[untitled]
XML文件的解析操作
请问,redis没有消费消息,都在redis里堆着是怎么回事?用的是cerely 。
When FC connects to the database, do you have to use a custom domain name to access it outside?
常用數字信號編碼之反向不歸零碼碼、曼徹斯特編碼、差分曼徹斯特編碼