Time for action – using DOM manipulation with OpenStreetMap map images

Reusing knowledge about OpenLayers renderers from Chapter 3, Charting the Map Class and OpenStreetMap from Chapter 4, Interacting with Raster Data Source, let's review how to manipulate the DOM and changing OpenStreetMap tiles sources on the fly.

So, let's start with the official OpenLayers example from http://openlayers.org/en/v3.0.0/examples/simple.html using Page inspector.

Open the file and at the end of the URL you get from your browser add ?renderer=dom

  1. Click on the Page Inspector icon (or right-click on image and click Inspect in the menu) and hover over the images. .
  2. Then, on one of the img tags, right-click on Edit attributes, as illustrated in the following screenshot: ...

Get OpenLayers 3 : Beginner's Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.