Book Image

OpenLayers 3.x Cookbook - Second Edition

By : Peter J. Langley, Antonio Santiago Perez
Book Image

OpenLayers 3.x Cookbook - Second Edition

By: Peter J. Langley, Antonio Santiago Perez

Overview of this book

OpenLayers 3 is one of the most important and complete open source JavaScript mapping libraries today. Throughout this book, you will go through recipes that expose various features of OpenLayers 3, allowing you to gain an insight into building complex GIS web applications. You will get to grips with the basics of creating a map with common functionality and quickly advance to more complicated solutions that address modern challenges. You will explore into maps, raster and vector layers, and styling in depth. This book also includes problem solving and how-to recipes for the most common and important tasks.
Table of Contents (14 chapters)
OpenLayers 3.x Cookbook Second Edition
About the Authors
About the Reviewer

Getting information from a WMS server

We've seen in earlier recipes that we can query external services for map tiles (WMS) and also for features (WFS). In addition to this, WMS servers can implement the GetFeatureInfo request. This type of request allows us to, given a point and some layer names that are configured at the WMS server, retrieve information from a feature; that is, we can get feature attributes from a layer, which is rendered as a raster image.

For example, there could be a WMS layer containing parking zones across your region, which can be drawn out as polygons over the map as part of the returned raster tiles. You could listen for a click event on the map and retrieve information from the WMS server in regards to the location that you clicked on. This may return data, such as parking fees, the name of the car park, how many spaces are still available, and so on.

OpenLayers makes this type of feature information request simple with a method called getGetFeatureInfoUrl, which...