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