Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mapbox Cookbook

You're reading from   Mapbox Cookbook Over 35 recipes to design and implement uniquely styled maps using the Mapbox platform

Arrow left icon
Product type Paperback
Published in Mar 2016
Publisher
ISBN-13 9781784397357
Length 264 pages
Edition 1st Edition
Tools
Arrow right icon
Toc

Table of Contents (8) Chapters Close

Preface 1. Introduction to Mapbox FREE CHAPTER 2. Mapbox Services 3. TileMill and Mapbox Studio 4. Mapbox.js 5. Mapbox.js Advanced 6. Mapbox GL Index

Creating a simple map

In this recipe, we will explore how we can integrate Mapbox.js into a project. We will use the absolute minimum code, and we will just display a simple map.

How to do it…

We have to create a simple HTML5 file that will include the necessary Mapbox.js JavaScript and CSS files.

We will also create our own CSS file to create some basic styling for our #map div that will contain the map. In main.js, we will initialize Mapbox.js and provide our Mapbox access token. Then, we will create a simple map by providing the basic coordinates. Perform the following steps:

  1. Open up the chapter-4-example1-starter folder. This folder contains an HTML5 index.html file, a css folder with a style.css file, and a main.js file. The project isn't linked to Mapbox.js yet; we will do this next.

    The style.css file contains some basic styling for the #map div. It will style the div with 100% width and 800px height, with no margins. This div will contain our map.

    We will use main.js to write...

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 $19.99/month. Cancel anytime
Banner background image