Webgis about Openlayers Getting Started (i) Installing and generating basic maps

Source: Internet
Author: User

A WEbgis version 2.12 used in the project

: https://github.com/openlayers/ol2/releases

Https://github.com/openlayers/ol2/blob/master/notes/2.12.md

Two Code Environment:

To add a map to the page, first introduce the corresponding openlayers Library, then create the map object and Add the map service The page will show you the map . re-create a folder in the download openlayers2.12 folder img,lib,theme folders and openlayers files, add code to the file.

Three Layers of Openlayers:

A useful map requires at least one layer, at least one base layer. Layers above other base layers are called overlay layers. The base layer and overlay layer are the two layer types in openlayers .

(1) First create a map container, load the layer

1. Create a map using the default parameter configuration. "Map1" is the HTML div, used to install the map container, can be set to size

var map = new Openlayers.map ("Map1");

2. Create some parameter configuration map var options = {
Projection: "epsg:3857",
Maxextent:new Openlayers.bounds (-200000,-200000, 200000, 200000),
Center:new Openlayers.lonlat (-12356463.476333, 5621521.4854095)
};
var map = new Openlayers.map ("MAP2", options);
3. Write the parameter configuration directly in the map

Code Explanation:

( 2 ) using Layer the steps: ? Create Layer Adds a layer to the Map , either with map.addlayer (layer) or Map.addlayers ([Layer1,layer2,.....]

Example: Creating a map and joining a WMS Base Layer

WMS is one of the more simple and important standards in the OGC standard. It is the full name of "Web Map Service". This standard defines three major operations for creating and displaying map images: getcapabilities (get service capability), GETMAP (get map), and Getfeatureinfo (Get object information). Where Getmap is the core operation, this operation obtains a map image.

Webgis about Openlayers Getting Started (i) Installing and generating basic maps

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.