> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/android/ja/java/llms.txt)

# Isochrone

This guide provides an overview of how to get time/distance **isochrones** using the Mapbox Java SDK.

The [Mapbox Isochrone API](https://docs.mapbox.com/api/navigation/isochrone/) computes areas that are reachable within a specified amount of time from a location and returns the reachable regions as contours of polygons and/or lines. If you're using this Java SDK wrapper with the Mapbox Maps SDK for Android, you can then display these areas or lines on a map.

For more information about this API, including its pricing structure, see the [Mapbox Isochrone API documentation](https://docs.mapbox.com/api/navigation/isochrone/). Along with the API documentation, you can also view [the Isochrone API example in the Mapbox Android demo app](https://docs.mapbox.com/android/ja/java/examples/isochrone/) to see a complete example of how to use the API.

## Criteria

Use the [`IsochroneCriteria` class](https://github.com/mapbox/mapbox-java/blob/master/services-isochrone/src/main/java/com/mapbox/api/isochrone/IsochroneCriteria.java) to conveniently reference a particular directions profile as you build the `MapboxIsochrone.builder()` object. Using the `IsochroneCriteria` class helps make sure that you pass correctly formatted parameters.

-   *Driving*: For automotive routing. This profile shows the fastest routes by preferring high-speed roads like highways.
-   *Walking*: For pedestrian and hiking routing. This profile shows the shortest path by using sidewalks and trails.
-   *Cycling*: For bicycle routing. This profile shows routes that are short and safer for cyclists by avoiding highways and preferring streets with bike lanes.

## Import packages

```java
import com.mapbox.api.isochrone.MapboxIsochrone
import com.mapbox.api.isochrone.IsochroneCriteria
import com.mapbox.geojson.FeatureCollection
```

## Building the URL

Start by creating a new instance of the `MapboxIsochrone` object and use its builder to customize your API request. The options offered in the builder include choosing whether the API returns polygon areas and the colors of those polygon areas.

If you're using this API with the Mapbox Maps SDK for Android, setting `true` for `.polygons(boolean)` will return polygon coordinates that you can then use for `FillLayer.` Isochrone lines can be used with `LineLayer`s.

**Java**

```java
MapboxIsochrone mapboxIsochroneRequest = MapboxIsochrone.builder()
	.accessToken(MAPBOX_ACCESS_TOKEN)
	.profile(IsochroneCriteria.PROFILE_DRIVING)
	.addContoursMinutes(listOfIntegers)
	.polygons(usePolygon)
	.addContoursColors(listOfHexColorValueStrings)
	.generalize(2f)
	.denoise(.4f)
	.coordinates(Point.fromLngLat(queryPoint.longitude, queryPoint.latitude))
	.build();
```

**Kotlin**

```kt
val mapboxIsochroneRequest = MapboxIsochrone.builder()
	.accessToken(MAPBOX_ACCESS_TOKEN)
	.profile(IsochroneCriteria.PROFILE_DRIVING)
	.addContoursMinutes(listOfIntegers)
	.polygons(usePolygon)
	.addContoursColors(listOfHexColorValueStrings)
	.generalize(2f)
	.denoise(.4f)
	.coordinates(Point.fromLngLat(queryPoint.longitude, queryPoint.latitude))
	.build()
```

## API response

In the response to a request to the Mapbox Isochrone API, the isochrone contours are returned as a GeoJSON Feature Collection. [More information about the response](https://docs.mapbox.com/api/navigation/#response-retrieve-isochrones-around-a-location).

The API will return a `FeatureCollection`:

**Java**

```java
mapboxIsochroneRequest.enqueueCall(new Callback<FeatureCollection>() {
	@Override
	public void onResponse(Call<FeatureCollection> call, Response<FeatureCollection> response) {

		if (response.body() != null && response.body().features() != null && response.body().features().size() > 0) {

		  FeatureCollection featureCollection = response.body();

		  List<Feature> responseFeatureList = response.body().features();

		}
	}

	@Override
	public void onFailure(Call<FeatureCollection> call, Throwable t) {

		Log.d(TAG, ("Request failed: %s", t.getMessage());

	}
});



```

**Kotlin**

```kt
mapboxIsochroneRequest.enqueueCall(object : Callback<FeatureCollection> {
	override fun onResponse(call: Call<FeatureCollection>, response: Response<FeatureCollection>) {

		val featureCollection = response.body()

		val responseFeatureList = response.body()?.features()

	}

	override fun onFailure(call: Call<FeatureCollection>, t: Throwable) {

		Log.d(TAG, ("Request failed: %s", t.message)

	}
})
```