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 – target practice

In this example, we'll use the target property to move the map around in our web page:

  1. Working from the previous example, add a second <div> tag for the map and a <button> tag after the <input> element we added for the bindTo() example. Change the class of both <div> tags to half-map—this class tells the <div> tag to only take up to 50 percent of the width of the page. When the user clicks the button, we'll move the map between the two <div> tags:
    <div id="map" class="half-map"></div>
    <div id="map2" class="half-map"></div>
    <input type="checkbox" id="visible" checked> Toggle Layer Visibility
    <button onclick="changeTarget();">Change Target</button>
  2. Now, we can add a function to the end of the <script> element 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