1. base layers & overlay layers
Base Layer: the lowest layer. Other layers are on top of the layer. The first layer to be added is the base layer by default.
Overlay layer: either base layer or overlay Layer
2. Steps for using layer:
- Create Layer
- Add layer to map. You can use map. addlayer (layer) or map. addlayers ([layer1, Layer2,...]
3. Example: Create a multi-layer map
<!DOCTYPE html>
Run the code and get the following results:
4. layer. WMS class resolution
First, let's take a look at the parameters of the layer. WMS class:
| Parameters |
Description |
| Name |
{String}, indicating the layer name
|
| URL |
{String}, indicating the base address of WMS |
| Params |
{Object} represents the query string and parameter value for obtaining the map. |
| Options |
{Object}, a hash table for other options added on the layer |
Name parameter:
The first parameter of the layer. WMS class, indicating the layer name and string type. The layer name should be placed in the reference to indicate that it is of the string type. The name is random. If a layer switching control is added to the map, the layer name is hidden in the control. Remember that there is a comma after the reference.
URL parameters:
The URL address of the Network Map Service.
Params parameters:
Is an anonymous object (Object?) containing key: value pairs ?) This parameter specifies the server settings that affect the map images returned by the WMS server. When openlayers sends a request to the map server, these key-value pairs will be appended to the URL address generated by openlayers.
Possible key: value pairs include:
Layers: Specifies the layer to be returned by the WMS Server
Transparent: a transparent image requested for layers such as the annotation Layer
SRS: Specifies the projection type.
Options:
Contains the attributes of the client openlaysers layer object. All layers have these parameters, mainly including isbaselayer, opacity, and visibility. Because the layer attribute is set by the client, therefore, WMS servers (or other servers) do not know these parameters.
5. Configure layer parameter example I:
<!DOCTYPE html>
The execution result of the program is:
Introduction to layer in openlayers