OPENLAYERS3 Basic Tutorial--loading resources

Source: Internet
Author: User

Overview:

This section describes how to load a WMS layer in OL3 and display it in a map.


OL3 Download:

You can download in OL official website, for http://openlayers.org/download/, also can go to my Baidu cloud disk download, for Http://pan.baidu.com/s/1o6wwHTo. The latest version of the official website is 3.6.0, the version of My network disk is 3.0.0, but the link on the official website seems to be invalid.


OL3 must introduce resources:

OL3 must be introduced with two resources, one for style files, ol.css; one for JS files, ol.js.


OL3 Loading WMS:

In Ol3, the WMS can be loaded in two ways, one of which is Ol.layer. Image, whose corresponding resource is Ol.source. Imagewms, the way he defines it, is:

var untiled = new Ol.layer.Image ({source:new Ol.source.ImageWMS ({ratio:1,url: ' http://localhost:8081/geoserver/ Lzugis/wms ', params: {' format ': Format, ' VERSION ': ' 1.1.1 ', LAYERS: ' Lzugis:province ', STYLES: '}}});

One is ol.layer. Tile, and its corresponding resource is Ol.source. tilewms, it is defined in the following way:

var tiled = new Ol.layer.Tile ({visible:false,source:new ol.source.TileWMS ({url: ' http://localhost:8080/geoserver/ Lzugis/wms ', params: {' format ': Format, ' VERSION ': ' 1.1.1 ', tiled:true,layers: ' Lzugis:province ', STYLES: '}}});


Show Resources:

OL3 Displays resources using map, a map instance includes target, the id;layers of the map display Div, a collection of layers for the map to be realistic, and a view, including projections, center points, and other information, defined in the following way:

var map = new ol. Map ({controls:ol.control.defaults {attribution:false}), Target: ' Map ', layers: [Untiled,tiled],view:new ol. View ({PROJECTION:PROJECTION,ROTATION:MATH.PI/6})}); Map.getview (). Fitextent (Bounds, map.getsize ());

Connect the above content, the complete code is as follows:


Related courses:

Basic concepts of OPENLAYERS3 Basic tutorial--ol3








Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

OPENLAYERS3 Basic Tutorial--loading resources

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.