ArcGIS API for flex-6. How many tasks can be restarted?

Source: Internet
Author: User

In the previous section, we learned about the task usage in the flex API. You can think of the task as a command. When you send the command to the server, the server will execute the command and return the result to you.-Of course, the premise is that the server must provide this service. The example in the previous section is identifytask. Other tasks can be bypassed. However, the names of API task packages are different because different tasks have different functions. Some tasks do not end with tasks. At the same time, not all tasks can execute. Therefore, we will focus on the functions and usage of various tasks in this section.

1. findtask
This is a simple task. Its function mainly uses keywords to search for certain fields of A element. If it matches, it returns the searched elements. You can refer to "findtask. mxml" in sample. The following code defines the task:
We seem to have been able to figure out the general routine of a task. Let's turn it into a parameter object, set the task to be completed by this task, and then associate the task with these parameters, finally, wait for the server to return the processing result. This findtask is concise and clear.

2. geometryservice
This is a task for processing geometric objects, but it ends with a service, which means it does not simply execute for you, it provides the ability to process multiple tasks. For example, buffer and lengths. Let's open "buffersample. mxml" of sample to see if this is a buffer example.

We can see that the processing process is no different from other tasks, except that no execute (you do not know what command to execute) replaces it with a clear task name, for example, the buffer method is used:
Mygeometryservice. buffer (bufferparameters );

Well, the question that comes with it is how to differentiate the results returned by different commands after the execution is complete? In fact, you only need to listen for different times. For example, if you execute the buffer command, you will listen to the buffer_complete event (in mxml: buffercomplete = "... "), okay, as long as your method listens to this event, you can handle it later after the buffer is complete.

3. geoprocessor
This is the task corresponding to the GP service. The GP service is flexible, so you need to pay more attention when setting geoprocessor task parameters (Object objects. There are not many new ideas in usage. For details, refer to "geoprocessormessageinabottle. mxml" in the sample ".

4. identifytask
The identification elements are old friends. For details, refer to the previous section.

5. Locator
Task that obtains an address from an address or an element. Let's open "locatortask. mxml" in the sample and see the code for executing the command:
Locatetask. addresstolocations (Addy, null, new asyncresponder (onresult, onfault ));

Locator provides two Commands: addresstolocations () and locationtoaddress (). Its parameters are also object objects, so flexible parameter settings and more error opportunities are provided.

6. querytask
Query element. Findtask is a command for searching text of certain fields, while querytask provides text query and space query capabilities. "Querytaskonmap. mxml" in the sample is an example of text query. Let's make some modifications to it for space query:

The query command is querytask.exe cute (query, new asyncresponder (onresult, onfault ));
Let's add:
Query. Geometry = map. extent;
Query. spatialrelationship = query. spatial_rel_intersects;

The preceding map is the ID of the map component (Added by yourself). At the same time, the text attribute previously defined in the query is deleted. After running the command, click query and drag the map to check whether only elements in the original view are highlighted? This is the result of the spatial query, because the preceding query uses the current map range as the filter condition.

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.