Mapbox Cookbook - Bill Kastanakis - E-Book

Mapbox Cookbook E-Book

Bill Kastanakis

0,0
34,79 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Over 35 recipes to design and implement uniquely styled maps using the Mapbox platform

About This Book

  • Design and develop beautifully styled maps using TileMill, MapBox Studio, and CartoCSS
  • Get to grips with the mapbox.js and Leaflet to create visually stunning web and mobile applications
  • An easy-to-follow, quick reference guide to integrate powerful APIs and services like Foursquare, Fusion Tables, Geoserver, and CartoDB to populate your maps

Who This Book Is For

If you are a web developer seeking for GIS expertise on how to create, style, and publish interactive and unique styled maps, then this book is for you. Basic knowledge of programming and javascripts is assumed.

What You Will Learn

  • Get accustomed to the MapBox Editor to visually style your maps
  • Learn everything about CartoCSS, and how it will help you fine tune your styled maps
  • Use MapBox Studio and Tilemill to generate your own tiles and vector maps
  • Publish your maps using a variety of technologies like node.js, PHP, and Geoserver
  • Integrate with third party APIs and services to populate your maps with public or private data
  • Create many different map visualization styles like choropleth and heat maps, add interactivity, and even learn how to animate data over time
  • Work with many different data formats and external services to create robust maps
  • Learn to use MapBox GL to create a mobile application

In Detail

Maps are an essential element in today's location aware applications. Right from displaying earth surface information to creating thematic maps displaying plethora of information, most of the developers lack the necessary knowledge to create customizable maps with combination of various tools and libraries. The MapBox platform is one such platform which offers all the tools and API required to create and publish a totally customizable map.

Starting with building your first map with the online MapBox Editor, we will take you all the way to building advanced web and mobile applications with totally customizable map styles. Through the course of chapters we'll learn CartoCSS styling language and understand the various components of MapBox platform and their corresponding JavaScript API.

In the initial few chapters we will dive deeper into the TileMill and MapBox Studio components of MapBox and use them to generate custom styled map tiles and vector maps. Furthermore, we will publish these custom maps using PHP, node.js and third party tools like Geoserver.

We'll also learn to create different visualizations and map styles like a choropleth map, a heat map and add user interactivity using a UFTGrid. Moving on, we dive into advanced concepts and focus on integration with third party services like Foursquare, Google FusionTables, CartoDB, and Torque to help you populate and even animate your maps.

In the final chapter we'll learn to use the Mapbox SDK to create and publish interactive maps for the iOS platform. By the end of this book, you will learn about MapBox GL and how to create a fully functional, location-aware mobile app, using the maps styles created in the recipes.

Style and approach

An easy-to-use recipe driven book that will not just serve code samples, but also explains all the theory and concepts required to fully understand each recipe.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 256

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

Mapbox Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why Subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Sections
Getting ready
How to do it…
How it works…
There's more…
See also
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Introduction to Mapbox
Introduction
Getting started with Mapbox
Data
Mapbox Editor
CartoCSS
TileMill
Mapbox Studio
API and SDK
Creating your own map
Getting ready
How to do it…
How it works…
Adding vector data
Getting ready
How to do it…
Creating a marker
Creating lines
Creating polygons
Modifying and deleting data
There's more…
Importing data
Editing imported data
Publishing your map
Getting ready
How to do it…
There's more…
Embedding a map in a self-hosted page
2. Mapbox Services
Introduction
Access tokens
Finding the Map ID
Accessing styled tiles on your map
How to do it…
How it works…
There's more…
Fetching a single tile
Creating static images
How to do it…
Creating the static map
Adding a marker
Finding coordinates for an address
How to do it…
How it works…
Query parameters
Returned results
Finding an address from coordinates
How to do it…
Finding an address on a map click
How to do it…
How it works…
Getting directions
How to do it…
How it works…
3. TileMill and Mapbox Studio
Introduction
Understanding TileMill
Understanding Mapbox Studio
Introducing CartoCSS
How CartoCSS works
Filters
Comparisons
Working with colors
Styling lines
Styling polygons
Styling labels
Attachments
Styling a map with TileMill
How it works…
How to do it…
Downloading the map data
Inspecting the downloaded files using QGIS
Importing downloaded data into TileMill
Styling data using CartoCSS
Styling a map with Mapbox Studio
How it works…
How to do it…
Styling a map
There's more…
Publishing your base map on your server with PHP
How it works…
How to do it…
Exporting a map from TileMill
Converting an MBTiles database into regular PNG files
Creating a tile server PHP project
Publishing your base map on your server with Node.js
Getting ready
How to do it…
Creating a tile server Node.js project
4. Mapbox.js
Introduction
Creating a simple map
How to do it…
How it works…
Changing map properties programmatically
How to do it…
Panning the map programmatically
Zooming the map programmatically
Zooming to a map region programmatically
How it works…
Working with base layers
How to do it…
Switching between layers
Adding markers and popups
How to do it…
Adding a basic marker with a popup
Creating markers using the geocoder
How it works…
Clustering markers to improve our map
How to do it…
Creating markers
Creating a simple polyline and polygon
Getting mouse coordinates
How to do it…
How it works…
Working with controls
How to do it…
Adding a zoom control to the map
How it works…
Adding interactivity to your map with UTFGrid
How to do it…
Creating an interactive map using TileMill
Creating an interactive map using Mapbox.js
How it works…
Creating a choropleth map
How to do it…
How it works…
Creating a heat map
How to do it…
How it works…
5. Mapbox.js Advanced
Introduction
Adding external data to your map
How to do it…
Loading external data
Loading a GPX file
How it works…
Adding a time dimension to your map
How to do it…
Importing the data to CartoDB
Using torque to visualize data over time
Comparing two maps at the same time
How to do it…
Comparing two maps
Adding a WMS layer from GeoServer to your map
How to do it…
Adding WMS images from GeoServer to your map
Installing GeoServer
Creating a layer
Displaying WMS layers using Mapbox.js
Adding ArcGIS layers from a server or from online
How to do it…
Adding ArcGIS layers from the server or from online
Adding Fusion Tables to your map
How to do it…
Acquiring a Fusion Tables API key
Creating a Fusion Table
Adding Fusion Tables data to your map
Adding Foursquare data to your map
How to do it…
Getting Foursquare data to your map
6. Mapbox GL
Introduction
Integrating your project with Mapbox GL
How to do it…
Creating the Xcode project file and linking it to Mapbox GL
Creating a basic map using Mapbox GL
How to do it…
How it works…
Switching between locations programmatically
How to do it…
How it works…
Adding markers to the map
How to do it…
How it works…
There's more…
Switching map styles
How to do it…
There's more…
One more thing…
How it works…
Loading GeoJSON and drawing a polyline
How to do it…
How it works…
Drawing polygons on the map
How to do it…
How it works…
Index

Mapbox Cookbook

Mapbox Cookbook

Copyright © 2016 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: March 2016

Production reference: 1150316

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78439-735-7

www.packtpub.com

Credits

Author

Bill Kastanakis

Reviewer

Balkan Uraz

Commissioning Editor

Usha Iyer

Acquisition Editors

Vinay Argekar

Shaon Basu

Content Development Editor

Siddhesh Salvi

Technical Editors

Siddhesh Ghadi

Taabish Khan

Copy Editors

Shruti Iyer

Sonia Mathur

Project Coordinator

Nidhi Joshi

Proofreader

Safis Editing

Indexer

Mariammal Chettiyar

Production Coordinator

Conidon Miranda

Cover Work

Conidon Miranda

About the Author

Bill Kastanakis has been a software engineer for over 15 years with experience in desktop, mobile, and web application development. His love for the Mapbox platform came from a project he worked on in 2010 to build a series of iOS tourist guide apps. With maps being simplistic in appearance and their customization options being nearly zero, he discovered the potential of a platform that allows the developer to totally customize the appearance of maps and the experience of using them.

Bill currently owns MindBomb, which specializes in mobile apps for the iOS platform, and he is a cofounder of nCoded+ Limited, which builds enterprise mobile and web applications for casino accounting. He also works as an iOS team lead and architect for one of the most popular apps in Ireland.

Bill often contributes to presentations as well as writing several mobile development blogs about new mobile technologies.

About the Reviewer

Balkan Uraz is a city planner with a master's degree in Geographical Sciences. He has over 18 years of experience in the field of Geographic Information Systems.

Throughout his career, Balkan has worked on several projects with one thing in common: GIS. In the early days of his career, he worked on projects involving municipal GIS and city information systems. He has worked on major LBS projects for mobile operators in Turkey that involve both software development and building data inventories. He cofounded a tech company that specializes in navigation data collection and products. He has also been a GIS consultant for major companies operating in the areas of field tracking and real estate. In all his projects, he has worked around his one passion, which is building up spatial infrastructure.

Balkan is the coauthor of the book Google Maps JavaScript API Cookbook with Alper Dincer, published by Packt Publishing.

www.PacktPub.com

eBooks, discount offers, and more

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why Subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

Preface

Maps are an essential element in today's location-aware applications, but they lack variation and customization. The Mapbox platform offers the tools and APIs required to totally customize, populate, and publish a map.

In this book, starting with the basics of Mapbox Editor for your first map styling steps, we will take you all the way to building advanced web and mobile applications with completely customizable map styles. The book focuses on the CartoCSS styling language as well as Mapbox tools and its JavaScript API, which inherits from Leaflet and is one of the most established, robust, and easy-to-use libraries.

We will then introduce two core Mapbox tools: TileMill and Mapbox Studio. Using them, we will generate custom-styled map tiles and vector maps. We will then move on to how to publish your custom maps using PHP, Node.js, and third-party tools such as GeoServer.

The next step is to start using the Mapbox JavaScript API and Leaflet to create different visualization map styles, such as a choropleth map and a heat map, and add user interactivity using UTFGrid.

We will continue with the advanced chapters and focus on integrating with third-party services such as Foursquare, Google Fusion Tables, CartoDB, and Torque to help us populate and even animate our maps.

Finally, we will end the book with a chapter dedicated to mobile devices. You will learn about Mapbox GL and how to create a fully functional, location-aware mobile app, which will use the map styles created in the earlier recipes.

This book is fast-paced, and the recipes are easy to follow. While it focuses on a recipe approach, it dives into the core concepts and theory of the technologies used to help you understand the theory required for GIS, web, and mobile development.

What this book covers

Chapter 1, Introduction to Mapbox, shows how to style your own base map using Mapbox Editor, add vector data, and publish your maps.

Chapter 2, Mapbox Services, shows how to use the lower-level Mapbox Web Services API to access data from the Mapbox servers.

Chapter 3, TileMill and Mapbox Studio, shows how to create stunning custom raster and vector maps using TileMill and Mapbox Studio.

Chapter 4, Mapbox.js, is an introduction to the Mapbox JavaScript API. This chapter will show how to create custom layers, add vector and raster data, and create interactivity and custom map styles such as choropleth and heat maps.

Chapter 5, Mapbox.js Advanced, shows how to use external data sources and integrate them with datasets from third-party services.

Chapter 6, Mapbox GL, shows how to create a fully functional mobile app using Mapbox GL for iOS.

What you need for this book

You require the following software:

A code editor, such as Sublime Text, Atom or BracketsThe latest versions of TileMill and Mapbox StudioThe latest version of Xcode and a Mac computerGIS software, such as QGIS (this is optional)A REST client, such as Postman for Chrome or PAW for Mac (this is optional)

Who this book is for

Whether you are a web developer looking to dive into the GIS world or a GIS professional looking to create advanced web and mobile applications, this book is for you.

Sections

In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).

To give clear instructions on how to complete a recipe, we use these sections as follows:

Getting ready

This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.

How to do it…

This section contains the steps required to follow the recipe.

How it works…

This section usually consists of a detailed explanation of what happened in the previous section.

There's more…

This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.

See also

This section provides helpful links to other useful information for the recipe.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

#layer { line-color: #C00; line-width: 1; }

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

<iframe width='100%' height='500px'frameBorder='0' src='https://a.tiles.mapbox.com/v4/nimrod7.k4adg5mg/attribution,zoompan,zoomwheel,geocoder,share.html?access_token=pk.eyJ1Ijoibmltcm9kNyIsImEiOiJkNkw1WWRnIn0.pnQn9P2nbHyhKf2FY_XJog'></iframe>

Any command-line input or output is written as follows:

git clone https://github.com/mapbox/tilestream.git .

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Copy the clipboard copy icon next to the Share textbox."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

Log in or register to our website using your e-mail address and passwordHover the mouse pointer on the SUPPORT tab at the top.Click on Code Downloads & Errata.Enter the name of the book in the Search box.Select the book for which you're looking to download the code files.Choose from the drop-down menu where you purchased this book from.Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR / 7-Zip for WindowsZipeg / iZip / UnRarX for Mac7-Zip / PeaZip for Linux

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/MapboxCookbook_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.

Chapter 1. Introduction to Mapbox

In this chapter, we will cover the following recipes:

Creating your own mapAdding vector dataPublishing your map

Introduction

Most websites we visit every day use maps in order to display information about locations or points of interest to the user. It is amazing how this technology has evolved over the past few decades.

In the early days, with the introduction of the Internet, maps were static images. Users were unable to interact with maps as they were limited to just displaying static information. Interactive maps were available only to mapping professionals, accessed via very expensive GIS software. Cartographers used this type of software to create or improve maps, usually for an agency or an organization. Again, if information about a location was to be made available to the public, there were only two options: static images or a printed version.

Improvements in Internet technologies opened up possibilities for interactive content. It was a natural transition for maps to become live, respond to search queries, and allow user interactions, such as panning and changing the zoom level.

Mobile devices were just beginning to evolve, and a new age of smartphones was about to begin. It was natural for maps to become even more important to consumers. Interactive maps are now in their pockets, and more importantly, they can tell a user's location and display a great variety of data.

In an age in which smartphones and tablets have become aware of location, information has become even more important to companies. Smartphones use this information to improve user experience in everything from general-purpose websites such as Google Maps, to more focused apps such as Foursquare and Facebook. Maps are now a crucial component in the digital world.

The popularity of mapping technologies is increasing over the years. A number of services have become available to developers, from free open source solutions to commercial services for web and mobile developers, and even services specialized for cartographers and visualization professionals.

Currently, developers have the option to choose from a variety of services that will work better for their specific tasks. The best part of all is that if some customers have increased traffic requirements, most of them are offered free plans.

Getting started with Mapbox

The issue with most of the solutions available is that they look extremely similar. By observing the most commonly used websites and services that implement a map, you can easily confirm that they completely lack personality.

Maps have the same colors and present the same features, such as roads, buildings, and labels. Currently, displaying road addresses on a specific website doesn't make sense. Customizing maps is a tedious task, and that is the main reason that it's avoided. What if the map provided by a web service does not work well with the color theme used in your website or app?

Mapbox is a service provider that allows users to select from a variety of customization options. This is one of the most popular features that set it apart from its competitors. The power to fully customize your map in every detail, including the color theme, features you want to present to the user, information displayed, and much more, is indispensable. Using the tools provided by Mapbox, you can upload and publish your own datasets and integrate them with Mapbox's own data.

Mapbox provides you with the tools to fully write in CartoCSS, the language behind Mapbox's cartographic customization, SDKs, and frameworks, to integrate their maps into your website with minimal effort, along with a lot more tools to assist you in your task and provide your users with a unique experience.

Data

Let's take a look at what Mapbox has to offer. We will begin with the three available datasets.

Mapbox Streets is the core technology behind Mapbox's street data. It's powered by Open Street Maps and has an extremely vibrant community of 1.5 million voluntary cartographers and users, who constantly refine and improve map data in real time.

Note

For more information regarding the Mapbox and Open Street Maps partnership, visit https://www.mapbox.com/guides/osm-and-mapbox/.

For more information regarding Open Street Maps, visit http://www.openstreetmap.org.

Mapbox Terrain is composed of datasets fetched from 24 other datasets owned by 13 organizations. It enables you to access elevation data, hill shades, and topography lines, as shown in the following figure:

Mapbox Satellite offers high-resolution cloudless datasets with satellite imagery, as shown in the following figure:

Mapbox Editor

Mapbox Editor is an online editor with which you can easily create and customize maps. Its purpose is for you to easily customize the map's color theme by choosing from presets or creating your own styles. Additionally, you can add features such as markers and lines, or define areas using polygons. Maps are also multilingual, and currently there are four different languages as options to choose from while working with Mapbox Editor:

While adding data manually in Mapbox Editor is handy, it also offers the ability to batch import data, and it supports the most commonly used formats.

The user interface is strictly visual. No coding skills are needed in order to create, customize, and present a map. It is ideal if you want to quickly create and share maps. It also supports sharing to all major platforms, such as WordPress, and embedding in forums or websites using IFrames.

CartoCSS

CartoCSS is a powerful open source-style sheet language developed by Mapbox and widely supported by several other mapping and visualization platforms. It's extremely similar to CSS, and if you have ever used CSS, it will be very easy for you to adapt. Take a look at the following code:

#layer { line-color: #C00; line-width: 1; } #layer::glow { line-color: #0AF; line-opacity: 0.5; line-width: 4; }

TileMill

TileMill is a free open source desktop editor that you can use to write CartoCSS and fully customize your maps. This is done by adding layers of data from various sources and then customizing layer properties using CartoCSS, a CSS-like style sheet language. When you complete the editing of the map, you can export the tiles and upload them to your Mapbox account in order to use the map on your website. TileMill was used as the standard solution for this type of work, but it used raster data. This changed with the introduction of Mapbox Studio, which uses vector data:

Mapbox Studio

Mapbox Studio is the new open source toolbox created by the Mapbox team to customize maps, and the plan is to slowly replace TileMill. The advantage is that it uses vector tiles instead of raster. Vector tiles are superior because they hold infinite detail; they are not dependent on the resolution found in a fixed-size image. You can still use CartoCSS to customize the map, and as with TileMill, you can export and share the map to your website at any point:

API and SDK

Accessing Mapbox data using various APIs is also very easy. You can use JavaScript or WebGL, or simply access the data using REST service calls. If you are into mobile development, separate SDKs are offered to develop native apps for iOS and Android that take advantage of the amazing Mapbox technologies and customization while maintaining a native look and feel.

Mapbox allows you to use your own sources. You can import a custom dataset and overlay the data on Mapbox Streets, Terrains, or satellite base maps. Another feature worth noting is that you are not limited to fetching data from various sources, as you can also query the tile metadata.

Creating your own map

In this recipe, you will be introduced to the core functionality of Mapbox Editor. In the beginning, we will explore the project management dashboard to create a new project. After this, we will use the interactive color picker provided by Mapbox Editor's user interface to help us style our new map.

The power of Mapbox Editor must not be underestimated. The functionality provided allows us to experiment with color schemes and gives our map a unique personality without writing a single line of code. The controls are simple, but at the same time there are options for sophisticated color mixing, making our task easier than ever.

Even if you advance deeper into the book and learn the secrets of CartoCSS, the powerful styling language that powers TillMill and Mapbox Studio, you will often use Mapbox Editor as a scratchpad to experiment with new ideas and color schemes.

Getting ready

To start working with Mapbox, you need to create a user account. This account is needed when you want to create a new project, use the editor, share data, and access the APIs for development; it is used to get a unique access token that you will use in the future when developing using the APIs.

Mapbox offers a free, non-time-limited plan that suffices for the scope of learning Mapbox as long as you do not have any heavy traffic on your published maps. There are limitations, especially when using Mapbox Studio, but you can start with a free plan and upgrade later when needed.

Head over to www.mapbox.com and click on Sign up in the upper-right corner. Follow the instructions to create a new account. After you have created it, simply sign in and select Projects from the menu:

How to do it…

The first step is to create a new project:

Once you have signed in, you will be transferred to the Projects screen. From here, you can create new projects, edit them, or delete them. You will also see the default API access token at the top of the screen, but we will get to that a bit later:Click on the Create project button, and you will be transferred to Mapbox Editor, where you can style or import data and save your map.

How it works…

You can pan simply by dragging the mouse on the map, and zoom using the mouse scroll wheel or the plus and minus buttons in the lower-left corner of the screen. Next to the zoom buttons, there is a handy box showing the current coordinates in latitude and longitude of the region currently on the screen. In the upper-left corner of the screen, you will see your profile picture and several buttons that give you access to the related sections. Next to the profile picture is Style, which is used to select one of the predefined map styles:

You can start customizing your map immediately by selecting one of the available preset styles to get started with a predefined color style. You can select any of the 15 available styles provided by Mapbox.

Note

There was a time when Mapbox allowed us to customize the color theme using Mapbox Editor.

Sadly, this functionality has now been removed, and Mapbox kindly reminds us that we can use Mapbox Studio to customize our maps. Don't worry; in the end, it's much more powerful to do it this way, and we will learn more about it in Chapter 3, TileMill and Mapbox Studio.

Adding vector data

Getting ready

Most of the time, you will be presenting a map in order to guide the user to a specific location. You can add a variety of vector data to your map, which can be markers if you want to show a POI (point of interest) to the user; lines, which represent a route from one location to another; and polygons, which can be used if you want to highlight an entire area.

How to do it…

There are a number of things that we can do with vector data in Mapbox. Here are a few of them.

Creating a marker

The following steps need to be performed:

Click on Data.Click on Marker and then click anywhere on the map. A marker will drop. You can adjust the marker's position by dragging it and dropping it at a different location.Add any title you like on the marker.For the description, you can use not only plain text, but also the <img> and <a> tags. Try adding the following code as the description:
Here is the location I told you about. Check out the images. More information <a href="http://www.wikipedia.com">here.</a> <img src="http://lorempixel.com/400/200/city/"></img>
Click on the Style tab. You can select a color of your choice for the marker and also its size from three predefined sizes.Click on the Symbol tab. Here, you can select an icon for your marker. Some personality is never bad!The last tab is Lat/Lon (Latitude/Longitude). You can type in the exact coordinate if you feel so inclined.

Creating lines

Mapbox Editor gives you the ability to create lines. Routes, for example, are best represented with lines. Perform the following steps:

Click on the Data tab.Click on Line and start the line by clicking anywhere on the map.