8. Use openlayers to implement the WebGIS Client
8.1 Introduction to openlayers
Log on to the http://www.openlayers.org and download the openlayers package.
Openlayers is a javascript package used to develop the WebGIS client. Openlayers methods for accessing geospatial data comply with industry standards. For example, the WMS and WFS specifications of OpenGIS. Openlayers adopts object-oriented development and uses components from prototype. js and RICO. The map sources supported by openlayers include WMS, GoogleMap, kamap, and msvirtualearth. You can also use simple images as the source. openlayers provides many options.
Since openlayers2.2, openlayers has used prototype. JS components are integrated into itself and are constantly involved in prototype. on the basis of JS, we have improved object-oriented development. Rico is not used much, but it is only used in openlayers. popup. the anchoredbubble class has a circular Div. Openlayers2.4 and later versions provide the Vector Plotting function to dynamically display geographical data such as points, lines, and faces.
8.2 instance description
Take creating an index.html as an example to view the map page. Import openlayers. js and the JS you are about to create. The content requires a DIV, whose ID is called area. You need to write some CSS limitation # the width and height of area. If you are willing to add a border, it is also a good choice.
First, we need to create an openlayer. map object instance:
VaR map = new openlayers. Map ("area ");
The parameters can be passed by ID or elementobject, which is more convenient.
Next, add a layer to the map. Generally, use the subclass of openlayers. layer to initialize the layer.
Openlayers provides the following layers extensions:
Openlayers. layer. Image
Openlayers. layer. httprequest
Openlayers. layer. Grid
Openlayers. layer. WMS
Openlayers. layer. kamap
Openlayers. layer. eventpane
Openlayers. layer. Google
Openlayers. layer. virtualearth
Openlayers. layer. Markers
Openlayers. layer. Text
Openlayers. layer. georss
Openlayers. layer. Boxes
Openlayers. layer. TMS
The image class encapsulates an actual image as the image's previous content
The httprequest class can receive a dynamically generated image. You can send parameters to the server through parameters of the httprequest class.
The grid class is a subclass of the httprequest class and provides more detailed methods.
The WMS class is used to connect to the WMS server to obtain images.
The kamap class is used to connect to the mapserver.
The eventpane class is used as a layer for receiving user operations.
Google class is used to get images from Google. It still requires you to get the API key from Google and include
Virtualearth layer used to operate virtualearth
The markers class is used to generate a layer for receiving and displaying users' local tags.
The text class is used to receive CSV files.
The georss class is a subclass of the marker class. It is used to encapsulate and receive georss and create marker in layers.
Boxes is also a subclass of the marker class. You can use Div as a marker instead of an image.
Map of TMS used to receive TMS servers
After creating a layer, you can use the addlayer (layer) method of map to insert it and execute the zoomtomaxextent () method of map to display the map properly.
Openlayers also provides a variety of control classes to add some tools for map browsing, inherited from the openlayers. control class.
Openlayers. Control. layerswitcher
Openlayers. Control. mousedefaults
Openlayers. Control. mouseposition
Openlayers. Control. mousjavaslbar
Openlayers. Control. overviewmap
Openlayers. Control. panzoom
Openlayers. Control. panzoombar
Openlayers. Control. permalink
Openlayers. Control. Scale
Examples of these classes will add some toolbar or buttons on the "window" of map browsing to increase interaction and functionality.
Openlayers encapsulates Common Data Structures
Openlayers. lonlat
Openlayers. Size
Openlayers. Pixel
Openlayers. Bounds
For ease of operation.
In addition, the openlayers. util class can customize the color of the image box and the default image in the image box when the image is loaded incorrectly, which is very convenient. The Ajax class of openlayers encapsulates the process of creating the XMLHTTPRequest object and can be used for simple Ajax operations.
IX. Appendix
1.Related Concepts
GIST |
Http://man.chinaunix.net/database/postgresql_8.0_CN/gist.html GIST means a general search tree ). It is a balanced access method with a tree structure. It plays a basic template in the system and can then be used to implement any index mode. B +-trees, R-trees, and many other index modes can be implemented using gist. One advantage of GIST is that it allows a custom data type to be developed together with an appropriate access method, and is developed by experts in this data type category rather than database experts. Some information is derived from the gist project website of UC berkeli and the papers of Marcel kornacker, access methods for next-generation database systems. PostgreSQL's gist implementation is currently mainly maintained by teodorsigae and Oleg bart.pdf, there are more information on their website: http://www.sai.msu.su /~ Megera/Postgres/gist /. |
R-TREE |
The R-tree index is used to index spatial data. A hash index cannot process range searches. B-tree indexes can only process one-dimensional Range searches. The R-tree index can process multidimensional data. For example, if you can create an R-tree index on a field of the point type, then, the system is more efficient in answering queries like select all points within a bounding rectangle (all vertices within a rectangle. Creating R-trees can process polygon and square shapes. Theoretically, R-trees can be extended to process more multidimensional data. However, in practice, extending R-trees requires a certain amount of work. |
WKB |
Well known binary is a binary storage method for GIS data. |
WKT |
Well known text |
Reprojection |
Re-projection |
Spatial_ref_sys table |
Space reference system table (spatial_ref_sys) is used to store space reference system information. The table structure is as follows: SRID is the space reference system code, and auth_name is the coordinate name of the Space reference system, auth_srid is the coordinate name code of the Space reference system, and srtext is the WKT (well-known text) text format of the Space reference system. The WKT data structure of the spatial reference system includes space. |
Coordinates |
Coordinate System |
Features |
Geometric element |
SRID |
Spatial referencing system identifier space reference system identifier. |
Populates |
Fill |
Schema |
Outline |
Meta-data |
Metadata |
2.Related Websites and discussion groups
OGC Official Website: http://www.opengis.org
PostgreSQL Official Website: http://www.postgresql.org
Udig Official Website: http://udig.refractions.net
Geoserver Official Website: http://www.geoserver.org
Openlayers Official Website: http://www.openlayers.org
Geotools Website: http://www.geotools.org
Geoserver QQ group: 4825849