Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying OpenLayers 3.x Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
OpenLayers 3.x Cookbook

OpenLayers 3.x Cookbook - Second Edition

By : J. Langley, Antonio Santiago
4 (1)
close
close
OpenLayers 3.x Cookbook

OpenLayers 3.x Cookbook

4 (1)
By: J. Langley, Antonio Santiago

Overview of this book

OpenLayers 3 is one of the most important and complete open source JavaScript mapping libraries today. Throughout this book, you will go through recipes that expose various features of OpenLayers 3, allowing you to gain an insight into building complex GIS web applications. You will get to grips with the basics of creating a map with common functionality and quickly advance to more complicated solutions that address modern challenges. You will explore into maps, raster and vector layers, and styling in depth. This book also includes problem solving and how-to recipes for the most common and important tasks.
Table of Contents (9 chapters)
close
close
8
Index

Creating a side-by-side map comparator

We are going to create a map comparator. The goal is to have two maps side-by-side from different providers and synchronize the same position and zoom level. The source code can be found in ch04/ch04-map-comparator. Here's a screenshot of our two synchronized maps, side-by-side:

Creating a side-by-side map comparator

How to do it…

To have two maps work in synchronization, perform the following steps:

  1. Create an HTML file with OpenLayers library dependencies. In particular, the markup for the two maps and separator should look like the following:
    <div id="js-map1"></div>
    <hr/>
    <div id="js-map2"></div>
  2. Create a custom JavaScript file and set up the shared view:
    var view = new ol.View({
      zoom: 5,
      center: [1252000, 7240000]
    });
  3. Instantiate the first map with the shared view, as follows:
    var map1 = new ol.Map({
      view: view,
      target: 'js-map1',
      layers: [
        new ol.layer.Tile({source: new ol.source.OSM()})
      ]
    });
  4. Finish off...
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
OpenLayers 3.x Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon