Java servlet mobile app access interface (III) Gaode map cloud storage and retrieval

This essay about Gaode map will be a little more,

1、 Business description

There are two types of members in the corresponding app business: one is the service personnel, and the other is the served personnel. It mainly realizes the function of locating the position of the service personnel in the app from time to time, and then calculates the distance unit m between the service personnel and the served personnel through a longitude and latitude provided by the served personnel when logging in to the app.

The following is the whole detailed process, from the creation of Gaode corresponding application (I won't mention it here) --- finally complete this function.

2、 Create Gaode map application corresponding to servlet and create its own cloud map database table

After registering your account, log in and click the console in the upper right corner. The following interface will appear. I'll take a screenshot

Of course, this is the interface I have already registered. If I don't register, I'll use a button to get the key. Here you can click directly to create your application. Take the application name casually, because we use a servlet to handle it

Relevant business, so the option is web service API. Here, click get key to display the following screenshot

After this step is completed, we can create the cloud chart we want. Enter the console, select the mouse to move to my data, and then select the following data management console (WEB) to enter the add cloud chart interface

The following is the screenshot after entering. After this screenshot, I will explain it directly in words.

The screenshot above is the result I created. Here, we need to first click the data template download in the upper right corner. After downloading the template, modify the corresponding data, add the required fields, and then click new map to download the template

Import the modified template into the cloud library. This template is actually a database table exported from excel. Next, I directly intercept the table I created. I added two fields to the table and set one field as an index field.

Remember that the red field name must be retained (the content can be modified at will). It is provided by the system template. The last two black fields are added by yourself and can be modified at will. Even after you upload them to Gaode cloud map server, you can change them.

After uploading the above table, you can open the previous data management (WEB) and the previous map interface will appear. There is a map box on the left. Click in to see the details of the person you uploaded and the Yellow five pointed star logo displayed on the map through the uploaded longitude and latitude. Here is a screenshot

The fields displayed in this table are modified by me, not uploaded in Excel just now. Click the title in the column to set a series of settings. I won't elaborate on this,

Just the setting of the index field,

After entering, I choose filter sort index -- > filter sort index is to set a filter condition for the newly added field of the user.

I use the user type of the screenshot in the cloud image above. I also give you the screenshot below.

At this step, we have completed the whole steps of creating and uploading cloud images... Next, I'll talk about the method called.

2、 Request method of servlet querying cloud image library

1. First paste the developer document address:

http://lbs.amap.com/yuntu/reference/cloudsearch/ I suggest you take a look at this

Here, the servlet uses the cloud retrieval API and the corresponding app uses the cloud storage API. Perhaps tomorrow, an article on the constant positioning of the IOS client corresponding to this interface will be added.

The following is the spliced URL format. Directly enter refresh in the URL to obtain relevant data in get mode.

http://yuntuapi.amap.com/datasearch/local?tableid=568bd32b305a2a31f604c650&city= Beijing & keywords =% 20 & filter = type: service personnel limit = 15 & page = 1 & key =? (the parameters key here are all your own)

The following is the encapsulated request method code

The following is the request method

String mapparameter = new string ("tableid = 568bd32b305a2a31f604c650 & city = Beijing & keywords =% 20 & filter = type: masseur limit = 15 & page = 1 & key =?" ") getBytes("ISO8859-1"),"UTF-8"); String returnResult=HttpRequest. sendPost(" http://yuntuapi.amap.com/datasearch/local ",mapParameter); out.println("

The filter criteria we query here are the fields we created (and set it as the index field) type: masseur ------------------- above_ The fields in front of Updatetime are the data put in our database, and the fields behind Updatetime are the real data queried through the transmitted longitude and latitude. However, when used in real use, these data are added from the app side, and the app also needs to transmit the name of the currently located city to the servlet, so the data here is wrong.

3、 The servlet calculates the distance between two longitudes and latitudes

Here is the distance between the served personnel and the service personnel calculated by the servlet through longitude and latitude. In fact, this is a one to many relationship. One served person can correspond to n persons providing services. The longitude and latitude of the location of the served personnel will match the longitude and latitude of all the service personnel queried this time to calculate the distance.

The method of calculating distance is posted below. This is a common method, which is applicable to all major maps.

For latlng in the parameter, you can create a class by yourself, which contains two fields of double type. One represents precision and one represents latitude. The process generated by using this method: when the user opens the app interface of the service personnel, he requests the interface to read the service personnel list. At this time, servlet needs to query the service personnel information in the Gaode cloud diagram once. The number of queries can be limited, and then query it. Cycle the longitude and latitude in each data with the longitude and latitude transmitted by the service personnel opening the app interface, The relative distance is calculated by matching. An IOS essay may be released tomorrow, which corresponds to this interface and is mainly posted on the code of the real-time positioning cloud map database implemented on IOS.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>