I am writing a new article in continuation of the previous one, since I immediately got offline an interesting question, why not actually use OpenLayers. Indeed, it can be used and, indeed, the implementation of hybrid cartographic representations is further simplified. In the new article I want to describe several ways to display data using OpenLayers. So, let's begin.
Ways to display spatial data using OpenLayersThe article discusses several ways to visualize spatial data using OpenLayers, the pros and cons.
')
OpenLayers is a free JavaScript library for displaying map data on web pages with APIs similar to the Google Maps / Virtual Earth API.
Depending on how the source data is stored and the requirements for the created cartographic representation on the web, there may be several approaches to displaying data on a web page. This article illustrates these approaches and gives examples of the software implementation of each of them.
Table of contents1. Direct data display
2. Display WMS layer
3. Download specialized data
1. Direct data displayThe fastest way to deploy. It consists in direct, without intermediaries, access to spatial data. OpenLayers allows you to directly display a limited number of vector and raster formats, which is the main disadvantage of this method. Unfortunately, at the time of this writing, it is impossible to work directly with the format format, but you can work with KML, JSON and some others. The second major drawback is the inability to display large data sets.
In the following example, a direct connection to the data set (border of the Republic of Kalmykia) in the KML format stored on the server and its visualization by means of OpenLayers is carried out.

2. Display WMS layer
The following example visualizes the data of a WMS service, launched using MapServer, for the WMS service using shape data (country borders). This way of displaying data allows you to work with a large list of vector formats, not limited to XML / JSON data representation, allows you to use complex conventions and to perform additional configuration of the cartographic presentation of data through the editing of the MapServer map file. Also, using this approach, fragment caches (tilecache) and well-constructed detailing depending on the scale are practically no restrictions on the amount of displayed data.
The disadvantages of this method include the relative complexity of setting up if the download needs to be done from your own WMS server, which enables installation and launch of MapServer, service configuration, etc. On the other hand, a configured WMS server allows you to use your data with any client software, both through specialized GIS software and through a browser, as in this example.
3. Download specialized dataAnother possibility of OpenLayers is downloading data provided through its API by various map services, such as OpenStreetMap, Google Maps, and many others. Since the implementation of their protocols is different from the OGC specifications, they are separated into a separate group of specialized data and managed using the OpenLayers.Layer.Google, OpenLayers.Layer.Yahoo family of objects, etc. Opportunities OpenLayers allow you to download such data together with the layers formed by the above methods, creating a hybrid cartographic representation. Displaying layers from different sources is one of the main functions of OpenLayers, allowing you to quickly customize any number of them. In OpenLayers, this is much easier than, say, directly showing the WMS MapServer layer in Google Maps (more). Paying for it comes from the overhead download of the very OpenLayers and the inability to use the original API, replaced by the OpenLayers API.
The simplest example of a hybrid representation can be implemented by the following script, using Google data as a base layer (topographic map and satellite images) and a WMS overlay layer obtained in the same way as in point 2.

Update 15.01, the
full version of the article is a more complete analysis of the code, working examples, and not pictures.