O'Reilly logo

OpenLayers 3 : Beginner's Guide by Erik Hazzard, Paul Spencer, Thomas Gratier

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

Time for action – starting with the default controls

Follow these steps to start manipulating the default controls:

  1. Create an HTML page using the usual template referring to the OpenLayers 3 JavaScript library and its default CSS, as shown here:
    <!doctype html>
    <html>
      <head>
        <title>Default controls</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/ol.js"></script>
        <script>
        </script>
      </body>
    </html>
  2. Now, between the empty <script> </script> add the declaration to the map:
    var osm_default = new ol.layer.Tile({ source: new ol.source.OSM() }); var map = new ol.Map({ layers: ...

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