当前位置:网站首页>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
边栏推荐
- wpf dataGrid 实现单行某个数据变化 ui 界面随之响应
- Is the compass stock software reliable? Is it safe to trade stocks?
- Social responsibility · value co creation, Zhongguancun network security and Information Industry Alliance dialogue, wechat entrepreneur Haitai Fangyuan, chairman Mr. Jiang Haizhou
- IP address home location query full version
- 最长上升子序列模型 AcWing 482. 合唱队形
- AI talent cultivation new ideas, this live broadcast has what you care about
- Excuse me, I have three partitions in Kafka, and the flinksql task has written the join operation. How can I give the join operation alone
- Advanced Mathematics - Chapter 8 differential calculus of multivariate functions 1
- Vmware 与主机之间传输文件
- 搜索框效果的实现【每日一题】
猜你喜欢
Redis can only cache? Too out!
最长上升子序列模型 AcWing 1014. 登山
UML 顺序图(时序图)
UML state diagram
The longest ascending subsequence model acwing 1012 Sister cities
VSCode 配置使用 PyLint 语法检查器
最长上升子序列模型 AcWing 482. 合唱队形
docker部署oracle
一个简单LEGv8处理器的Verilog实现【四】【单周期实现基础知识及模块设计讲解】
Advanced Mathematics - Chapter 8 differential calculus of multivariate functions 1
随机推荐
requires php ~7.1 -&gt; your PHP version (7.0.18) does not satisfy that requirement
手把手教会:XML建模
请问,在使用flink sql sink数据到kafka的时候出现执行成功,但是kafka里面没有数
搜索框效果的实现【每日一题】
[untitled]
Leetcode——344. 反转字符串/541. 反转字符串 II/151. 颠倒字符串中的单词/剑指 Offer 58 - II. 左旋转字符串
AutoCAD - how to input angle dimensions and CAD diameter symbols greater than 180 degrees?
手里的闲钱是炒股票还是买理财产品好?
[fortress machine] what is the difference between cloud fortress machine and ordinary fortress machine?
How can the PC page call QQ for online chat?
SAKT方法部分介绍
Lavarel之环境配置 .env
Hangdian oj2092 integer solution
Supply chain supply and demand estimation - [time series]
数据流图,数据字典
Es log error appreciation -limit of total fields
杭电oj2092 整数解
Seven propagation behaviors of transactions
When FC connects to the database, do you have to use a custom domain name to access it outside?
接口自动化测试-接口间数据依赖问题解决