当前位置:网站首页>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-06
uni.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
nvue
Support 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
边栏推荐
- Excerpt from "misogyny: female disgust in Japan"
- PostgreSQL array type, each splice
- Wired network IP address of VMware shared host
- Verilog implementation of a simple legv8 processor [4] [explanation of basic knowledge and module design of single cycle implementation]
- call undefined function openssl_cipher_iv_length
- c#通过frame 和 page 切换页面
- Mysql怎样控制replace替换的次数?
- 【立体匹配论文阅读】【三】INTS
- [AI practice] Application xgboost Xgbregressor builds air quality prediction model (II)
- XML文件的解析操作
猜你喜欢
带你掌握三层架构(建议收藏)
Advanced Mathematics - Chapter 8 differential calculus of multivariate functions 1
高等數學---第八章多元函數微分學1
SAKT方法部分介绍
【立体匹配论文阅读】【三】INTS
通过 iValueConverter 给datagrid 的背景颜色 动态赋值
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文件的解析操作
How to check the ram and ROM usage of MCU through Keil
随机推荐
股票开户首选,炒股交易开户佣金最低网上开户安全吗
Selenium库
Clickhouse (03) how to install and deploy Clickhouse
Excuse me, why is it that there are no consumption messages in redis and they are all piled up in redis? Cerely is used.
What are the principles for distinguishing the security objectives and implementation methods that cloud computing security expansion requires to focus on?
Huawei image address
Excellent open source system recommendation of ThinkPHP framework
Assign a dynamic value to the background color of DataGrid through ivalueconverter
交换机和路由器的异同
Leetcode——236. 二叉树的最近公共祖先
最长上升子序列模型 AcWing 1012. 友好城市
call undefined function openssl_cipher_iv_length
NDK beginner's study (1)
Csma/cd carrier monitoring multipoint access / collision detection protocol
oracle 非自动提交解决
When FC connects to the database, do you have to use a custom domain name to access it outside?
oracle 触发器实现级联更新
IP address home location query full version
数据流图,数据字典
Arm cortex-a9, mcimx6u7cvm08ad processor application