Mapbox Cookbook
上QQ阅读APP看书,第一时间看更新

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 pes 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 Brackets
  • The latest versions of TileMill and Mapbox Studio
  • The latest version of Xcode and a Mac computer
  • GIS 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 pe 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 , 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:

  1. Log in or register to our website using your e-mail address and password
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. 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 Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-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 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 , and we will do our best to address the problem.