More

Zoom to the extent of the WMS layer in GeoServer by OpenLayers 3?

Zoom to the extent of the WMS layer in GeoServer by OpenLayers 3?


I would like to use OpenLayers 3 (I saw similar question for OpenLayers 2) to display a GeoServer layer using WMS, and zoom to the extent of the layer automatically by getting the extent information from this layer. Just like when preview the layer on GeoServer, it displays the layer within the layer's extent and no matter what the CRS of the layer is.

I have installed Opengeo suite 4.5 and created a viewer with the suite-sdk viewer template. I debug with suite-sdk debug -g http/to/geoserver path/to/app

The viewer uses OpenLayers 3 library. I have added OSM layer and my GeoServer layer with ol.source.TileWMS source and display them successfully.

I get the capabilities of my local GeoServer WMS service (ol3 example). With the results, by checking the name of each layer, I would like to zoom to my target layer.

// // the codes add layers to ol.map and intial the ol.view // // TODO: zoom to layer var featurePrefix = '***'; var featureType = '***'; var url = 'http://localhost:port/geoserver/wms?request=GetCapabilities&service=WMS&version=1.1.1'; var parser = new ol.format.WMSCapabilities(); $.ajax(url).then(function(response) { var result = parser.read(response); var Layers = result.Capability.Layer.Layer; var extent; for (var i=0, len = Layers.length; i

With the code above, I can get the BBOX of the layer in its own coordinate system other thanESPG::3857. But the map did not zoom to that layer. I think it is a coordination system problem.

How can I solve it, or another approach to get the extent?

(I found the current code is not nice)


Just useol.proj.transformExtentin between to transform your extent. You can also uselayer.latlonBBOXfrom theGetCapabilitiesparser output so you always know the source bounding box is in EPSG:4326.


Following the suggestions from user23054, I solved the problem like this:

In the geoserver webadmin interface "Edit layer data and publishing" page, section "Coordinate Reference Systems", set the declared SRS to ESPG: 4326, the set "Reproject Native to Declared".

So the code will always get the extent as in ESPG 4326. Then applyol.extent.applyTransform(extent, ol.proj.getTransform("EPSG:4326", "EPSG:3857"));

theol.proj.transformExtent(extent, "EPSG:4326", "EPSG:3857")does not work for me. I do not know what is wrong here.


Use this:

map.getView().fit(extent, map.getSize());

instead offitExtent. Only use the functionfitWorked for me. i have all my layers already in 3857.


8.1 Viewing a WMS in QGIS

Quantum GIS (QGIS) is an open source geographic information system and an official projext of the Open Source Geospatial Foundation (OSGeo) available for download. The instructions here apply to version 1.8.0.

      Open QGIS and navigate to the toolbar at the top of the window. Select 'Add WMS Layer' from the toolbar options.

Copy and paste this URL into the URL box and select an appropriate name for the layer e.g. OS Open Data, and select OK [3]. OS Open Data should now be an option in the drop down menu in the layers tab. Repeat the instructions for step 2 (ii) to request and display the OS Open Data WMS from Edina.

Right click on the layes added and select 'Zoom to layer extent' so that you can explore the OS Open Data layers. As you zoom into the layer you will notice that the data transitions from one OS Open Data product to another. The WMS is using scale dependencies to decide at what spatial scale a data layer is to be viewed as defined by the SLD file.


Installing TileCache

Generally, installing TileCache is as simple as downloading a source distribution and unpacking it. For installation systemwide, you can also use the Python Package Index (aka pypi or Cheeseshop) to install TileCache. Simply type easy_install TileCache. Once this is done, you will need to install the TileCache configuration file. A tool to do this is installed, called tilecache_install_config.py. A full installation likely looks like:

TileCache is also available as a Debian package from the TileCache homepage. This Debian package is designed to install on Debian etch releases or later. This Debian package should install on Ubuntu Feisty or Gutsy.


OpenLayers. Layer

The layer&rsquos opacity. Float number between 0.0 and 1.0. Default is 1.

AlwaysInRange

If a layer&rsquos display should not be scale-based, this should be set to true. This will cause the layer, as an overlay, to always be &lsquoactive&rsquo, by always returning true from the calculateInRange() function.

If not explicitly specified for a layer, its value will be determined on startup in initResolutions() based on whether or not any scale-specific properties have been set as options on the layer. If no scale-specific options have been set on the layer, we assume that it should always be in range.

Constants

RESOLUTION_PROPERTIES

The properties that are used for calculating resolutions information.

Properties

Events

Register a listener for a particular event with the following syntax

Listeners will be called with a reference to an event object. The properties of this event depends on exactly what happened.

All event objects have at least the following properties

Supported map event types

loadstartTriggered when layer loading starts.
loadendTriggered when layer loading ends.
visibilitychangedTriggered when layer visibility is changed.
moveTriggered when layer moves (triggered with every mousemove during a drag).
moveendTriggered when layer is done moving, object passed as argument has a zoomChanged boolean property which tells that the zoom has changed.
addedTriggered after the layer is added to a map. Listeners will receive an object with a map property referencing the map and a layer property referencing the layer.
removedTriggered after the layer is removed from the map. Listeners will receive an object with a map property referencing the map and a layer property referencing the layer.

This variable is set when the layer is added to the map, via the accessor function setMap().

IsBaseLayer

Whether or not the layer is a base layer. This should be set individually by all subclasses. Default is false

Alpha

The layer&rsquos images have an alpha channel. Default is false.

DisplayInLayerSwitcher

Display the layer&rsquos name in the layer switcher. Default is true.

Visibility

The layer should be displayed in the map. Default is true.

Attribution

Attribution string, displayed when an OpenLayers.Control.Attribution has been added to the map.

InRange

The current map resolution is within the layer&rsquos min/max range. This is set in OpenLayers.Map.setCenter whenever the zoom changes.

Options

An optional object whose properties will be set on the layer. Any of the layer properties can be set as a property of the options object and sent to the constructor when the layer is created.

EventListeners

If set as an option at construction, the eventListeners object will be registered with OpenLayers.Events.on. Object structure must be a listeners object as shown in the example for the events.on method.

Gutter

Determines the width (in pixels) of the gutter around image tiles to ignore. By setting this property to a non-zero value, images will be requested that are wider and taller than the tile size by a value of 2 x gutter. This allows artifacts of rendering at tile edges to be ignored. Set a gutter value that is equal to half the size of the widest symbol that needs to be displayed. Defaults to zero. Non-tiled layers always have zero gutter.

Projection

or Specifies the projection of the layer. Can be set in the layer options. If not specified in the layer options, it is set to the default projection specified in the map, when the layer is added to the map. Projection along with default maxExtent and resolutions are set automatically with commercial baselayers in EPSG:3857, such as Google, Bing and OpenStreetMap, and do not need to be specified. Otherwise, if specifying projection, also set maxExtent, maxResolution or resolutions as appropriate. When using vector layers with strategies, layer projection should be set to the projection of the source data if that is different from the map default.

Can be either a string or an OpenLayers.Projection object if a string is passed, will be converted to an object when the layer is added to the map.

Units

The layer map units. Defaults to null. Possible values are &lsquodegrees&rsquo (or &lsquodd&rsquo), &lsquom&rsquo, &lsquoft&rsquo, &lsquokm&rsquo, &lsquomi&rsquo, &lsquoinches&rsquo. Normally taken from the projection. Only required if both map and layers do not define a projection, or if they define a projection which does not define units.

Scales

An array of map scales in descending order. The values in the array correspond to the map scale denominator. Note that these values only make sense if the display (monitor) resolution of the client is correctly guessed by whomever is configuring the application. In addition, the units property must also be set. Use resolutions instead wherever possible.

Resolutions

A list of map resolutions (map units per pixel) in descending order. If this is not set in the layer constructor, it will be set based on other resolution related properties (maxExtent, maxResolution, maxScale, etc.).

MaxExtent

<<OpenLayers.Bounds>|Array>If provided as an array, the array should consist of four values (left, bottom, right, top). The maximum extent for the layer. Defaults to null.

The center of these bounds will not stray outside of the viewport extent during panning. In addition, if displayOutsideMaxExtent is set to false, data will not be requested that falls completely outside of these bounds.


OneGeology

The OneGeology Portal is found at: http://portal.onegeology.org/ and is accessible as either an English (the default) or French language service.

You will need to use Internet Explorer 6 and above, Firefox 2 and above or recent versions of Safari, Opera, and Chrome. You will need to enable JavaScript and allow pop-ups.

When you open the OneGeology Portal you get a map of the world, the Blue Marble: Next Generation+Topo+Bathy (Terra/MODIS) (http://visibleearth.nasa.gov/view_detail.php?id=7105) . By default you now also get some automatically selected geology map layers, depending on the scale you are zoomed into. For example, at full map extent you now get the ‘World CGMW 1:50M Geological Units Onshore’ map.

Default display of the OneGeology Portal, with automatically selected geology layers

You may at any time turn off the automatically selected layers by unticking the option ‘Automatically displayed layers depending on scale and location’ in the top right of the browser window.

The overview window in the bottom right corner of the map indicates the area of the globe you are currently looking at in the map window, by means of a red outline map superimposed on the global map. For example in the above map the red outline is shown for the whole globe, but in the below map the red box is located in the Southern Ocean.


The overview window shows where you are on the globe


Add OneGeology map layers icon

To view any other registered geology maps you need to click on the ‘Add OneGeology map layers’ icon to open the OneGeology Portal catalogue listing.


OneGeology Portal catalogue map layers listed by Geographic area. Use the options in this window to control which maps are displayed, and how they are displayed

Click on the + buttons to expand the levels. Select a map by clicking on the box to the left of the map you wish to view. A tick will appear.

Select all the map layers you wish to view at this time before closing the catalogue listing. The selected maps should then be visible. You can add other layers later on if you desire.

You may navigate around the map using the GIS tools found at the top of the page. The functions of these tools is as follows (from left to right):


GIS tools

  • Zoom in — click on this image and then click on the world background map to zoom in centred on the clicked location. Click and drag a rectangle to zoom to a specific area.
  • Zoom out — click on this image and then click on the world background map to zoom out centred on the clicked location. Click and drag a rectangle to zoom out from a specific area
  • View full global extent — click this image to start again with a view of the full world background map.
  • Pan by clicking and dragging the map to move — click this image and then click and drag on the map to move to a different area (north, west, etc)
  • Return back to previous map view
  • If you have gone back to a previous view, you may use this tool to go forward.
  • Use this tool to get more information about the active map layers (this is termed a GetFeatureInfo request). Select the tool and click the map to open up a new window with detailed information about the geology at that point. The information returned and format of the information varies from map to map and layer to layer dependant upon how much information the provider organization wishes to display and the capabilities of the service.


Example of information that may be retrieved using the information tool


Active Layers Properties icon

To view metadata about the map layers and to change the way the layers are displayed you need to Click on the ‘Active Layers Properties’ icon. This will open a list of all the map layers that you have selected to be viewed in the OneGeology Portal it will now also display all the map layers that have been automatically selected.


Active layers in a OneGeology Portal session

Within this dialogue menu you can manage the individual layers in the following ways (looking at the icons from left to right):


Tools to manage the active layers

  • Move the map layer up (so it lies above other layers and may obscure them), and move the map layer down (so it lies beneath other layers and may be obscured by them). In the figure we can see that we cannot move the SUR TNO 1M SLT further up because the up away is greyed out.
  • Show or hide the map layer.
  • Change the opacity of the map layer (use the slider rule to change the % value to make underlying maps visible) so that it is possible to see through a layer to underlying layers where they overlap
  • Zoom to the extent of the map layer to make that particular map layer fill the centre of the map browser.
  • Delete the map layer from the view (you can add it back again later).

Note the i icon has no actual function, it just exists to inform you whether the layer is queryable, that is whether you can perform a GetFeatureInfo request on it and get back some information. Note too, in the above figure that one of the layers is shown to be greyed out. A greyed out layer indicates that the layer (such as PER INGEMMET 1:1M Faults, is not visible at the selected map scale. Finally note we can show or hide all the automatically selected layers by unticking the ‘Automatically displayed layers depending on scale and location’ option at the top of the dialogue window.


Layer viewed with 30% opacity


Layer viewed with 100% opacity

To find out further information about any map layer you can click the arrow to right of the layer title inforamtion found here is extracted from the service GetCapabilites response document and includes information such as:

  • The data owner
  • The service title
  • The legend of the map layer
  • Information about the layer data and other digital data services of the data provider
  • TC211/ISO 19115:2003 or FGDC metadata for the layer
  • The service URL (you can use this URL to view the OneGeology WMS layer in any WMS client as described in later sections).


Example of GetCapabilities data that may be obtained from the Active Layer properties dialogue, with pop-up legend from the Legend link

This (above) information is harvested automatically by the OneGeology Portal client software from the GetCapabilities response document of the WMS.

Go To


The Go To icon

Click on the Go To (compass) icon to open a dialog box that allows you to zoom to an area by place name or Longitude and Latitude coordinates

In the first example (below) we enter Dominica in the ‘Localisation by Name’ text box, then click the ‘Go to’ button to the right of it. This opens a second window that shows all the matches for Dominica in the OneGeology Portal gazeteer. Select the place name you want by clicking on it and the OneGeology Portal will zoom to that location. Note the OneGeology Portal only zooms to the area, it doesn’t necessarily open any available geology layers in that area.


Using the Go To functionality to zoom to an area (the Dominican Republic),
by entering a search string

In the second example (below) we use the ‘Localisation by Coordinates’ form and enter 172.85 in the ‘Long:’ text box and -43.73 in the ‘Lat:’ text box and then click the ‘Go to’ button to the right of them. The OneGeology Portal will then zoom to the area of interest. Note the OneGeology Portal only zooms to the area, it doesn’t necessarily open any available geology layers in that area. In this example we already had the geology of New Zealand as an active layer.


Using the Go To functionality to zoom to the area of Christchurch, New Zealand,
by entering the Longitude and Latitude

Viewing layers in different projections

The portal allows you to select other projections to view the map layers. The projections supported by the portal are:
EPSG:3031 Antarctic Polar Stereographic (WGS84) http://spatialreference.org/ref/epsg/3031/ EPSG:3034 Lambert Conformal Conic (ETRS89) http://spatialreference.org/ref/epsg/3034/ EPSG:3413 NSIDC Sea Ice Polar Stereographic North (WGS84) http://www.spatialreference.org/ref/epsg/3413/ EPSG:3857 Web Mercator (WGS84) http://spatialreference.org/ref/sr-org/7483/ EPSG:4258 2D Latitude / Longitude (ETRS89) http://www.spatialreference.org/ref/epsg/4258/ EPSG:4326 2D Latitude / Longitude (WGS84) http://spatialreference.org/ref/epsg/4326/

The default projection to view layers in the portal is 2D Latitude / Longitude (WGS84) or EPSG:4326. All layers in the portal must support this projection as part of their service. To select another projection you must use the list at the bottom of the main portal window. The current projection is shown in bold in the list, so for example in the below figure the active projection at the time of clicking the list was NSIDC Sea Ice Polar Stereographic North (WGS84).


Projections are selected from the list at the bottom of the main portal window

Whilst all layers in the portal must support 2D Latitude / Longitude (WGS84), other projections are optional. When you choose to change to any projection other the default, you should expect that some layers will not support the newly selected projection layers that do not support the selected projection are deselected (so the portal will not make any requests to them for map layers) and shown in the active layers properties window with a yellow warning triangle.


Active layers that do not support the projection are deselected and shown with a warning triangle

In many cases viewing the OneGeology layers in the default projection is sufficient, but in some cases, for example when you are dealing with layers close to the poles, a differnt projection better shows the data. For example compare the two images below showing map layers for Antarctica and surrounding regions. In the first example we have the default projection that shows Antarctica as a distorted strip of land at the bottom of the flattened globe.


Map layers from the Southern hemisphere showing in the the standard 2D Latitude / Longitude (WGS84)

In the second example, we have the same map layers shown in the Antarctic Polar Stereographic (WGS84) projection that shows Antarctica as it should be, as a single land mass. Note that the portal uses a different backdrop for this projection than that used for the default projection, namely the Landsat Image Mosaic of Antarctica (LIMA). Note too that this LIMA backdrop does not extend much further than the Antarctica land mass, so whilst there are map layers that support this projection other than Antarctica, for example the Falkland Islands (Malvinas) layers, there is currently no backdrop for these map layer extents.


Map layers from the Southern hemisphere showing in the Antarctic Polar Stereographic (WGS84)

Examples of other map layers in other projections are shown below:

NSIDC Sea Ice Polar Stereographic North (WGS84)


Map layer displayed in NSIDC Sea Ice Polar Stereographic North (WGS84) projection


Map layers displayed in Web Mercator (WGS84) projection

2D Latitude / Longitude (ETRS89)


Map layers displayed in 2D Latitude / Longitude (ETRS89) projection

Note that when using the ETRS-89 based projections you will not be able to zoom out (or pan the map) wider than than the intended extent of the projection.


Building the App

Preparing the Metadata

The first thing we need for our app is a data file that maps the short, unpractical column names in our census table to human readable information. Fortunately, the dictionary.txt file has all the information we need. The dictionary.txt file was created by copy pasting the text of the Buurten en Wijken documentation pdf in a text file and combining this with a list of all the columns of the Buurten en Wijken dataset with a python script.

The list of column names was necessary because the documentation of the Buurten en Wijken en dataset lists a lot more attributes than the file that we have downloaded from the NGR.

Here’s a couple example lines from the dictionary.txt file :

  • P_HH_M_K: Huishoudens met kinderen [%]
  • GEM_HH_GR: Gemiddelde huishoudensgrootte [absoluut]
  • P_WEST_AL: Westers totaal [%]

Each line has the column name and a human readable description. Fortunately the information is nicely seperated by a colon in the text file, so the fields can be extracted by using a split(":") function.

We’re going to consume this information in a JavaScript web application. The text file can easily be read in and split into lines. Each line can be split into an array with at position 0 the attribute code and at position 1 the attribute description to populate a topics dropdown.

Framing the Map

We already saw our map visualized in a bare OpenLayers 2 map frame in the Layer Preview section of GeoServer.

We want an application that provides a user interface component that manipulates the source WMS URL, altering the URL viewparams parameter.

We’ll build the app using Bootstrap for a straightforward layout with CSS, and OpenLayers 3 as the map component.

The base HTML page, index.html, contains script and stylesheet includes bringing in our various libraries. A custom stylesheet gives us a fullscreen map with a legend overlay. Bootstrap css classes are used to style the navigation bar. Containers for the map and a header navigation bar with the aforementioned topics dropdown are also included, and an image element with the legend image from a WMS GetLegendGraphic request is put inside the map container.

The real code is in the wijkenkaart.js file. We start by creating an Openbasiskaart base layer, and adding our parameterized census layer on top as an image layer with a WMS Layer source.

We configure an OpenLayers Map, assign the layers, and give it a map view with a center and zoom level. Now the map will load.

The select element with the id topics will be our drop-down list of available columns. We load the dictionary.txt file, and fill the select element with its contents. This is done by adding an option child for each line.

Look at the the wijkenkaart.js file to see the whole application in one page.

When we open the index.html file, we see the application in action.


Openlayers wms layer example

Qittu-problem-with-wfs-layer-in-openlayers-closed.pdf - Problem with wfs layer in OpenLayers closed Asked by Brunci on I m trying to add a wfs layer and it s not working. Here is full code: WebGis. legend padding-left:.

Openlayers_introduction.pdf - Creating a Web based GIS with the use of OpenLayers 1. Introduction to the OpenLayers API . Next, a new WMS overlay layer should be added to the map.

Nwiups-openlayers-ogc-filter-problem.pdf - Openlayers: OGC Filter problem Asked by Pask23 on I have a problem with OGC filter. My layer in OpenLayers has this filter: property: datetime , lowerBoundary:.

Openlayers_1j.pdf - OpenLayers La cartographie internet en Javascript 1 jours OBJECTIFS : · Comprendre la syntaxe Javascript pour utiliser OpenLayers · Manipuler les fonctions OpenLayers · Créer.

Openlayersv3-condensed.pdf?forcedownload=1 - A GUIDE TO OPENLAYERS V3 Objectives In this exercise you will learn the how to: Create a web map with HTML5 and JavaScript (OpenLayers v3) Add spatial content (maps and web map services to a website with OpenLayers 3 Add controls for manipulating the spat

5320.pdf - OpenLayers Plugin - Bug 5320: Qgis crashes when loading any layer from Openlayers plugin Status: Closed Priority: High Author:.

Rwrqy-openlayers-ajax-loading-works-on-ff-but-doesnt-work-on-chrome-any-idea-why.pdf - OpenLayers: Problems adding WMS layer to OSM OpenLayers and custom Proj4 Projection Rqgg Page 1/2. Openlayers ajax loading works on FF but doesnt work on Chrome.

04-basemap.doc - Change the base layer by clicking on the OpenLayers Layer Switcher and selecting Virtual Earth Aerial.

Suiteintro.pdf - var world= new OpenLayers.Layer.WMS("Earth", "/geoserver/wms", . OpenLayers Tutorial 135. Introduction to The OpenGeo Suite, Release March 18, 2012 Bonus & Discussion

Nwmnzx-user-input-in-openlayers-problem.pdf - User Input in Openlayers Problem Asked by TimothyDalton on I thought you could give me some advice regarding my problem. I have a working WFS Layer.

Diplomarbeit_wengerter.pdf - OpenLayers ist ein Projekt der Open Source Geospatial Foundation (OSGeo)13. Das geografische Wiki14 OpenStreetMap15 nutzt ebenfalls Open­ Layers zur Darstellung der Karten. 2.1 Testumgebung Nach der Vorstellung von OpenLayers beschreibt der folgende Absc

Uhws-ext-js-4-2-and-openlayers-without-geoext.pdf - Ext JS 4. 2 and OpenLayers without GeoExt Asked by Adanali on Is it possible to use only Ext JS 4. 2 and OpenLayers 2. 12 without GeoExt or anything else to make a basic map application I couldn.

Ryztu-custom-openlayers-design.pdf - Custom OpenLayers Design Asked by Mehdiway on I want to change the default UI for OpenLayers Zoom bar, direction. using my own images, which have.

537520035.pdf - OpenLayers – Vergangenheit, Gegenwart, Zukunft Andreas HOCEVAR Zusammenfassung Die Web-Mapping und Web-GIS Bibliothek OpenLayers hat seit ihrer ersten Version im Juni 2005 und der Veröffentlichung als Open Source Software im Juni 2006 die Nutzung und V

Plum-rund-um-openlayers-intergeo2009.pdf - [email protected]> | WebGIS-Applikationen – Was kommt nach OpenLayers? | InterGEO 2009 Agenda OpenLayers – die freie JS-Bibliothek zur Darstellung von OGC-komformen Web-

Zk_in_navis_tos2011.pdf - ZK Server+Client Fusion with OpenLayers Navis Framework ZK Map.js Application Server ZK Map.java Navis Yard Planning & Controlling App OpenLayers Javascript lib Map.java Map.js Controller openlayers.js lang-addon.xml zk.wpd 1. Encapsulate mapping func

Disruptive-memory-sang-yun-lee.pdf - BeSang Inc. Expansion Capability Memory Size: 1x 2x 4x 8x 3D Super-NAND: 1-layer 2-layer 4-layer 8-layer … Other 3D NANDs: 64-layer 128-layer 256-layer 562-layer … In order to double memory capacity . 017 • SHANG A C . Disruptive Memory Technology .

Nwirnh-openlayers-vector-feature-popup.pdf - Openlayers Vector Feature Popup Asked by Christer on im trying to create a popup in Openlayers that would open when someone clicks.

Lab_6.doc - 1. Computer networks structures, net topologies Fundamentals: OSI reference model: Layer 7 Application layer Layer 6 Presentation layer Layer 5 Session layer.

?action=browse&path=%2f*checkout*%2fdocumentos%2freferencia%2fopenlayers_2_10_beginners_guide.pdf - and promote their good uses in the Galician region), . Did you know that Packt offers eBook versions of every book published, . download a copy of OpenLayers .

Download our openlayers wms layer example eBooks for free and learn more about openlayers wms layer example. These books contain exercises and tutorials to improve your practical skills, at all levels!

To find more books about openlayers wms layer example, you can use related keywords : Openlayers Wms Layer Example, LAYER 7 OSI Model LAYER 6 LAYER 5 LAYER 4 LAYER 3 , Spanning Tree Protocol In Layer 2/layer 3 Environments, Openlayers Wms Example, Openlayers Wms, Openlayers 3, Openlayers Wms Filter, Openlayers Wms Projection, Mastering OpenLayers 3.pdf, Openlayers Cookbook Pdf

You can download PDF versions of the user's guide, manuals and ebooks about openlayers wms layer example, you can also find and download for free A free online manual (notices) with beginner and intermediate, Downloads Documentation, You can download PDF files (or DOC and PPT) about openlayers wms layer example for free, but please respect copyrighted ebooks.


1、 GeoServer 的跨域问题

同源策略是浏览器的一个安全限制,从一个源加载的文档或者脚本默认不能访问另一个源的资源。例如 a.com/111/html 页面不能访问 b.com/person 这种接口,因为他们是不用的源。注意:下面几个不受同源策略限制
①页面中链接(例如页面的 <a href="http://www.w3school.com.cn"> W3School)、重定向和表单提交不受同源策略限制
②跨域资源的引入是不受同源策略的限制,但是js读不到其中的内容。 <script src=". "></script>,<img>,<link>,<iframe> 等。
而正因为这个原因,会出现跨域问题,而在不修改代码的情况下解决这一问题有两种方式,一为 CORS ,二为通过服务器代理。(但在html与js编写过程中也要注意声明 serverType: 'geoserver' )

1.1 CORS

Tomcat(Not GeoServer) 的 web.xml 里添加如下过滤器代码,因为来源为apache,因此不需要添加额外的 jar 包.添加完之后,再重启 Tomcat 即可.

1.2 通过代理


Basic GIS object

Where GIS icon set was applied:

    - Geographic Resources Analysis Support System is a software for performing spatial analysis. It consists of more than 350 modules for processing vector (2D/3D), raster and voxel data. QGIS - Quantum GIS is a user friendly Open Source Geographic Information System (GIS) that runs on GNU/Linux, Unix, Mac OSX, and Windows. - tool for designing customised web maps, using a skin based mapping template. (Swing components) - open source Java library that provides tools for geospatial data. - open source framework for web interactive maps based on MapServer an OpenLayers. Nice example application for Brasil.
  • . place for your application

From gridsets to tiles¶

The following describes the process of interpreting the gridset and gridsubset at a particular zoom level and determining which tiles are being requested. This process described below is repeated for every zoom level.

Initial bounding box - Assume the gridset bounding box is (-10.0,-30.0,85.0,21.0) and that the resolution for the zoom level is set to 11.25 degrees / 256 pixels = 0.04395 (Scale 1:1.8e7)

Gridset aligned bottom-left to the bounding box - The specified bounding box does not correspond to an integer number of tiles, so GeoWebCache expands the bounding box to (-10.0,-30.0,91.25,26.25).

Gridset aligned to the top-left of the bounding box - The default is to align the bounding box to the bottom left. This is assumed by tiling WMS clients and TMS. However, for WMTS it makes more sense to align to the top left corner. If <alignTopLeft> is set to true, GeoWebCache will expand toward the bottom instead. In this case the bounding box becomes (-10.0,-36.75,91.25,21.0).

Gridsubset bounding box - Since a particular layer may not cover the entire gridset, GeoWebCache uses a gridsubset, which can specify only a portion of the gridset. If no extent is specified, it is assumed that the layer covers the entire gridset. This example uses the gridsubset extent of (-14.0,-15.0,48.0,16.0).

Gridsubset tiles - GeoWebCache will round up the extents to the nearest tile boundaries.


Watch the video: How to create map with GeoServer Open Layer and WMS. WFS?