Introduction to layer in openlayers

Source: Internet
Author: User

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:

  1. Create Layer
  2. 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

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.