Let's create a new OpenLayers application and identify the components as we go:
First, create a new file called
components.html
in the sandbox directory and put in the standard HTML structure for our applications as follows:<!doctype html> <html> <head> <title>OpenLayers Components</title> <link rel="stylesheet" href="../assets/ol3/css/ol.css" type="text/css" /> <link rel="stylesheet" href="../assets/css/samples.css" type="text/css" /> </head> <body> <div id="map" class="map"></div> <script src="../assets/ol3/js/ol.js"></script> <script> </script> </body> </html>
Now, we can add our code inside the second, empty script tag. First, we'll create a layer to display our map. The layer will be added to the map's
layers
collection:var layer = new ol.layer.Tile({ source: new ol.source.OSM() });
Next, we'll create an interaction...