Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Mapbox Cookbook

You're reading from  Mapbox Cookbook

Product type Book
Published in Mar 2016
Publisher
ISBN-13 9781784397357
Pages 264 pages
Edition 1st Edition
Languages

Table of Contents (13) Chapters

Comparing two maps at the same time


In this recipe, we are going to learn how to compare two maps at the same time. We can have two maps that are styled differently and which display different features. For example, one may use street data, while the other may use terrain or satellite imagery. The user will be able to swipe between the two maps.

How to do it…

The following steps need to be performed:

  1. Add an HTML5 slider input control to the DOM.

  2. Add an overlay map layer at the top of the base layer.

  3. Calculate the clipping point based on the slider input value.

  4. Create a rect, and apply that to the clip CSS property of the map container.

We first create an overlay map, and add it at the top of the base map. Next, we use a simple HTML5 input control, a range slider. As the user drags the slider, the overlay map gets clipped. All the magic happens in CSS. We have an overlay layer already in place, and we clip it based on the input value of the range slider. The CSS property that we are tweaking on...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}