Finereport How to get the address location on the mobile side

Source: Internet
Author: User

For most employees of the enterprise, because the work location is fixed, there can be many ways to clock in to ensure that the employee to work on time, but for frequent travel, to the customer site staff, there is no guarantee that they have to go to work, So hope to be able to position the mobile phone location to ensure that employees have normal work.

The above situation can be achieved by The Finereport template adds a button control that, when clicked, gets the current location, copies the location information to a cell, and finally the employee submits the current template.

To achieve the effect as shown, click the Location button to get the current position with the current time and display the corresponding cell below:

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M00/8D/1C/wKiom1iGzKXg7bx7AAAIPnu6anE200.png-wh_500x0-wm_3 -wmp_4-s_3790008326.png "title=" 1.png "alt=" Wkiom1igzkxg7bx7aaaipnu6ane200.png-wh_50 "/>

Template making

Open the designer, create a new template, design the template as shown in the style, where E2 cell is a button control, the control name is a geographic location, C5 is a drop-down box control, and E5 is a Time control:

650) this.width=650; "Src=" Http://s5.51cto.com/wyfs02/M02/8D/1C/wKiom1iGzLOy704EAAALnvhq2Ns476.png-wh_500x0-wm_3 -wmp_4-s_431481398.png "title=" 2.png "alt=" Wkiom1igzloy704eaaalnvhq2ns476.png-wh_50 "/>

Get Current Location

There are two ways to get the current location, one is to click the button to get a location, one is to open the template directly when the location, in the example, want to achieve by clicking the button to obtain the geographical location.

1) get a location by clicking the button

Open the control location for the button and add a click event for the control, such as:

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/8D/19/wKioL1iGzRLBqD8ZAACwVViFSYI300.png-wh_500x0-wm_3 -wmp_4-s_1511448319.png "title=" 3.png "alt=" Wkiol1igzrlbqd8zaacwvvifsyi300.png-wh_50 "/>

The corresponding code is as follows:

Fr.location (status, message) {//Get geolocation if (status== "Success") {//Locate successful, message returns latitude and longitude value FR.Msg.alert ("Current position is" + message); Contentpane.setcellvalue (2, 3, message);} else {//failed to locate, message returns the corresponding error message FR.Msg.alert (message);//Location failed});

Finereport gets the current position through the Fr.location method, or if the status value is success, the acquisition is successful, otherwise the location fails, and if the location is successful, the returned geo-location information is assigned to the C4 cell.

Note that this method is only useful on the mobile side, and if you click on the button event in the Web to obtain a geographic location, the direct prompt for location failure.

2) Get the current location after loading ends

If you want to get to the current location after the template is loaded, simply add the above code to the post-load event, open the template, click Templates > Templates Web Properties > Fill in the page settings, add a load end event such as:

650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M01/8D/19/wKioL1iGzVXBo7XdAAEaMATzpZU809.png-wh_500x0-wm_3 -wmp_4-s_986243336.png "title=" 4.png "alt=" Wkiol1igzvxbo7xdaaeamatzpzu809.png-wh_50 "/>

Get current time

the current check-in time in the template also needs to be assigned to the past, so you also need to get the current time in the button's click event, which gives E2 Cell adds a click event and assigns a value to the E4 cell with the following code:

var mydate = new Date (), var mytime=mydate.getfullyear () + "-" +mydate.getmonth () +1+ "-" +mydate.getdate () + "" + Mydate.gethours () + ":" +mydate.getminutes () + ":" +mydate.getseconds (); Gets the current time Contentpane.setcellvalue (4, 3, mytime);

button Click event All code is as follows:

Fr.location (status, message) {//Get geolocation if (status== "Success") {//Locate successful, message returns latitude and longitude value FR.Msg.alert ("Current position is" + message); Contentpane.setcellvalue (2, 3, message), var mydate = new Date (), var mytime=mydate.getfullyear () + "-" + Mydate.getmonth () +1+ "-" +mydate.getdate () + "+mydate.gethours () +": "+mydate.getminutes () +": "+mydate.getseconds (); Gets the current time Contentpane.setcellvalue (4, 3, mytime); } else {//failed to locate, message returns the corresponding error message FR.Msg.alert (message);//Location failed});

Effect view

Add the template to the tree of nodes in the data decision system, where the template is previewed in such a way as:

650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/8D/1C/wKiom1iGzYHxOAhHAABF8Tfgze8460.png-wh_500x0-wm_3 -wmp_4-s_2624566084.png "title=" 5.png "alt=" Wkiom1igzyhxoahhaabf8tfgze8460.png-wh_50 "/>

Log in to the system with the mobile side, access the template, click the Location button to get the current location and current time, such as:

650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/8D/19/wKioL1iGzbShXEaOAADZxKg88M8241.png-wh_500x0-wm_3 -wmp_4-s_4003535089.png "title=" 6.png "alt=" Wkiol1igzbshxeaoaadzxkg88m8241.png-wh_50 "/>

The geographical location acquired in Finereport is longitude and latitude, and if you need to determine its exact location, you will need to convert it separately.


Finereport How to get the address location on the mobile side

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.