(12) Design of vector layer in Webgis

Source: Internet
Author: User

1. Preface

In the first few chapters we've learned about what vector queries are, the transformations before screen coordinates and geographic coordinates, and the design of features, and with this knowledge, we can finally design vector layers in this chapter.

When creating a featureclass in the catalog, we can choose to create a point layer or a line layer or a polygon layer. The so-called point layer, that is, the features in the layer can only be points, and several other layers as the name implies. So in Webgis, we can also design our vector layer according to this design idea in ArcGIS, although this method is certainly feasible, but in the actual business requirements, if according to this point layer and so on strict control, the code flexibility and simplicity will be greatly reduced. So how do we design our vector layers to achieve the best results? Let's talk about it here.

2. Put forward several requirements

(1). There is a road that needs to be shown on the map, and each node on the highway must be clearly labeled.

(2). You need to show the location of a fire squadron and display it as a buffer of service radius.

(3). If you want to show the location of the individual concerned on the map, and then move the mouse over the person icon, you can have a bubble pop-up to show the person's current relevant information.

3. Analysis of requirements

If we were to design according to the idea of a midpoint, line, and polygon layer in ArcGIS, we would need to design two layers, a line layer, and a polygon layer in the first requirement. Similarly to the second requirement, we also need to create a point layer and a polygon layer.

Now, can we change the way we think about it, can we combine point layers, line layers, and polygon layers into one business layer? For example, the first requirement, in fact, as long as the line features and point features are added to the same canvas, a business-divided vector layer is generated.

Similarly, the solution to the second problem is to integrate point features and polygon features (round features) together. The third problem is easier to solve, just add point (icon) elements. In the design of the elements we have explained that each element is inherited uicomponent, can listen to mouse events, so the demand for pop bubbles will naturally be realized.

4. Design drawings

5. Design flowchart

6. An explanation of the case

Here, we explain the problem in the first way in the previously proposed requirements.

In the first step, the client lists the request parameters, such as the ID number of the road that needs to be displayed, and then sends the request to the vector service. For the shortest path analysis, the start and end points can be used as parameters to send requests to the NA service in the background.

The second step is to parse the data returned by the server. Derive the geometry and attribute of each element in the data. The corresponding features are instantiated according to the Geometrytype in geometry, and geometry and attribute are used as attributes of the instantiated feature. In this requirement, you first need to instantiate the same number of line features based on the returned line feature data. At the same time, the point features are instantiated according to the endpoint information in the geometry of the line features.

The third step is to add all the instantiated point and line features to the corridor layer (Canvas) and trigger the paint function for each feature. Since each feature has an internal implementation of redrawing and coordinate transformations, we do not need to implement the same functionality in the canvas.

However, here I need to explain a problem, in our homemade layer, we still need to listen to map events to do some necessary action. This operation is related to the translation of the map. Otherwise, when the map is dragged, the feature on the layer is redrawn, and an offset problem occurs. As mentioned in the previous section, the problem of feature migration in the map I will spend a special section on the future to discuss with you.

7. Summary

So far, in this series, I've finished the design of the raster layers and vector layers and the content involved. For the display of the map and the implementation of some basic business customization, I think we should all have some ideas. In the next series, I would like to discuss with you the design and implementation of basic functions in the Map toolbar, such as Zoom in, zoom out, pan, full map, I query, point of interest query, location, etc. I hope you will continue to pay attention. I wish you a happy holiday.

----Welcome reprint, but retain the copyright, please indicate the source in obvious place: http://www.cnblogs.com/naaoveGIS/

To live is to suffer, to experience, to understand exactly what we need.

(12) Design of vector layer in Webgis

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.