Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
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

Finding coordinates for an address

There are times when you have an address or just a city or a country, and you try to find the coordinates (latitude and longitude). The reverse is also true; you may have the latitude and longitude and want to get an address. This process is called geocoding.

Reverse geocoding is useful if, for example, we create a marker using the latitude and longitude and want to show the marker's address. Mapbox services also give you the ability to get the coordinates (latitude and longitude) from an address; this process is called forward geocoding.

How to do it…

The following steps need to be performed:

  1. Construct a GET request by specifying the master source and query.
  2. Paste the request in the browser or in a REST client.

    You will get back a JSON with coordinates that match your query.

The format of the requests has to be similar to the following:

{dataset}/{lon},{lat}.json?access_token=<your access token>

A complete request will look similar to the following...

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