-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Mapbox Cookbook
By :
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.
There are a number of things that we can do with vector data in Mapbox. Here are a few of them.
The following steps need to be performed:
<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>

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


There are times when you need to pinpoint a specific area to the user. While you can somehow archive this to an extent by enclosing the area using lines, there is a better and easier way, which is to use polygons:

To modify a marker, line, or polygon, perform the following steps:
Clicking on the button with three horizontal lines on the right-hand side of the Polygon tab (often called the Hamburger icon) displays a list of features. If you can't select something, you can use this menu to find the feature in question.
We have seen how easy it is to add features such as markers, lines, and polygons. However, each time, we have to create them one by one.
This would be tedious if we wanted to create several hundred or even thousands of them. The import feature of Mapbox Editor does exactly this. It allows us to import several well-known file formats, such as GeoJSON, CVS, KML, and GPS. Most GIS software, organizations, and services out there are able to export in one of these formats; they are used widely in the GIS and web-development landscape all over the world.
It's probably a good time to explain what these formats are:
Each file can contain multiple layers. By layer, we mean multiple features that are grouped together.
We will import a GeoJSON file that contains earthquake data for the last seven days by performing the following steps:


The map will zoom out, and the imported features will appear on the map with the fields that we selected as the title and description.
You can access imported data by clicking on the hamburger icon on the data screen next to the polygon button. You will be presented with a list of every feature you imported. This section is composed of two tabs: the first one lists the features, and the other lists the layers. GeoJSON and KML are formats that can contain features grouped into multiple layers:

Clicking on an item in the featured list allows us to edit it. We can change the title, description, color, size, and icon of the feature where available, as different types of feature have different attributes that we can modify.
Clicking on the trash can icon next to an item allows us to delete these specific features.
Change the font size
Change margin width
Change background colour