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

Retrieving remote data with OpenLayers.Request

Data is the basis for a web mapping application. We can add raster or vector layers to the map, which will load images or vector information.

In the case of vector layers, thanks to the OpenLayers.Protocol and OpenLayers.Format subclasses, we can configure the layer to load data from different sources and with different formats.

Anyway, there can be circumstances where we need to request data by ourselves, read the specific format, and add features. We are talking about making asynchronous JavaScript calls.

This recipe shows how we can use the helper class OpenLayers.Request to asynchronously request data from the remote servers.

Here, we are going to request a URL that returns random x and y values that ...

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