O'Reilly logo

OpenLayers Cookbook by Antonio Santiago Perez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Getting feature information from data source

We work on web mapping applications almost every day. We know how to create a map and add raster and vector layers. More than that, we know how to get vector data from different data sources: GeoJSON file, KML file, or from a WFS server.

At this point, and related to vector layers, one of the possible questions we could have is: how can we retrieve the feature's information? Fortunately, OpenLayers offers us some controls that can answer this question.

In this recipe, we are going to see in action the OpenLayers.Control.GetFeature control class that has the ability to query the feature's data source.

We are going to create a map with a base layer and two vector layers. One from a WFS server, with the USA, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required