You are previewing Mapbox Cookbook.
O'Reilly logo
Mapbox Cookbook

Book Description

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.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased 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 code file.

    Table of Contents

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