Class TrafficAsyncClient
AzureKeyCredential
:
// Authenticates using subscription key AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY")); // Creates a builder TrafficClientBuilder builder = new TrafficClientBuilder(); builder.credential(keyCredential); builder.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)); // Builds the client TrafficAsyncClient client = builder.buildAsyncClient();
// Authenticates using Azure AD building a default credential // This will look for AZURE_CLIENT_ID, AZURE_TENANT_ID, and AZURE_CLIENT_SECRET env variables DefaultAzureCredential tokenCredential = new DefaultAzureCredentialBuilder().build(); // Creates a builder TrafficClientBuilder builder = new TrafficClientBuilder(); builder.credential(tokenCredential); builder.trafficClientId(System.getenv("MAPS_CLIENT_ID")); builder.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS)); // Builds a client TrafficAsyncClient client = builder.buildAsyncClient();
-
Method Summary
Modifier and TypeMethodDescription__Traffic Flow Segment__Mono<com.azure.core.http.rest.Response<TrafficFlowSegmentData>>
__Traffic Flow Segment__Mono<com.azure.core.util.BinaryData>
getTrafficFlowTile
(TrafficFlowTileOptions options) __Traffic Flow Tile__Mono<com.azure.core.http.rest.Response<com.azure.core.util.BinaryData>>
__Traffic Flow Tile____Traffic Incident Detail__Mono<com.azure.core.http.rest.Response<TrafficIncidentDetail>>
__Traffic Incident Detail__Mono<com.azure.core.util.BinaryData>
__Traffic Incident Tile__Mono<com.azure.core.http.rest.Response<com.azure.core.util.BinaryData>>
__Traffic Incident Tile____Traffic Incident Viewport__Mono<com.azure.core.http.rest.Response<TrafficIncidentViewport>>
__Traffic Incident Viewport__
-
Method Details
-
getTrafficFlowTile
__Traffic Flow Tile__System.out.println("Get Traffic Flow Tile:"); // options asyncClient.getTrafficFlowTile( new TrafficFlowTileOptions() .setTrafficFlowTileStyle(TrafficFlowTileStyle.RELATIVE_DELAY).setFormat(TileFormat.PNG).setZoom(10)); // complete asyncClient.getTrafficFlowTile( new TrafficFlowTileOptions() .setTrafficFlowTileStyle(TrafficFlowTileStyle.RELATIVE_DELAY).setFormat(TileFormat.PNG).setZoom(10) .setTileIndex(new TileIndex().setX(2044).setY(1360)).setThickness(10));
**Applies to**: S0 and S1 pricing tiers.
The Azure Flow Tile API serves 256 x 256 pixel tiles showing traffic flow. All tiles use the same grid system. Because the traffic tiles use transparent images, they can be layered on top of map tiles to create a compound display. The Flow tiles use colors to indicate either the speed of traffic on different road segments, or the difference between that speed and the free-flow speed on the road segment in question.
- Parameters:
options
-TrafficFlowTileOptions
the options to be used in this search.- Returns:
- the response.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.traffic.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getTrafficFlowTileWithResponse
public Mono<com.azure.core.http.rest.Response<com.azure.core.util.BinaryData>> getTrafficFlowTileWithResponse(TrafficFlowTileOptions options) __Traffic Flow Tile__System.out.println("Get Traffic Flow Tile:"); // options asyncClient.getTrafficFlowTile( new TrafficFlowTileOptions() .setTrafficFlowTileStyle(TrafficFlowTileStyle.RELATIVE_DELAY).setFormat(TileFormat.PNG).setZoom(10)); // complete asyncClient.getTrafficFlowTile( new TrafficFlowTileOptions() .setTrafficFlowTileStyle(TrafficFlowTileStyle.RELATIVE_DELAY).setFormat(TileFormat.PNG).setZoom(10) .setTileIndex(new TileIndex().setX(2044).setY(1360)).setThickness(10));
**Applies to**: S0 and S1 pricing tiers.
The Azure Flow Tile API serves 256 x 256 pixel tiles showing traffic flow. All tiles use the same grid system. Because the traffic tiles use transparent images, they can be layered on top of map tiles to create a compound display. The Flow tiles use colors to indicate either the speed of traffic on different road segments, or the difference between that speed and the free-flow speed on the road segment in question.
- Parameters:
options
-TrafficFlowTileOptions
the options to be used in this search.- Returns:
- the response.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.traffic.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getTrafficFlowSegment
__Traffic Flow Segment__System.out.println("Get Traffic Flow Segment:"); // options asyncClient.getTrafficFlowSegment( new TrafficFlowSegmentOptions() .setTrafficFlowSegmentStyle(TrafficFlowSegmentStyle.ABSOLUTE).setZoom(10) .setCoordinates(new GeoPosition(4.84239, 52.41072))); // complete asyncClient.getTrafficFlowSegment( new TrafficFlowSegmentOptions() .setTrafficFlowSegmentStyle(TrafficFlowSegmentStyle.ABSOLUTE).setZoom(10) .setCoordinates(new GeoPosition(4.84239, 52.41072)).setOpenLr(false) .setThickness(2).setUnit(SpeedUnit.MPH));
**Applies to**: S0 and S1 pricing tiers.
This service provides information about the speeds and travel times of the road fragment closest to the given coordinates. It is designed to work alongside the Flow layer of the Render Service to support clickable flow data visualizations. With this API, the client side can connect any place in the map with flow data on the closest road and present it to the user.
- Parameters:
options
-TrafficFlowSegmentOptions
the options to be used in this search.- Returns:
- this object is returned from a successful Traffic Flow Segment call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.core.exception.HttpResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getTrafficFlowSegmentWithResponse
public Mono<com.azure.core.http.rest.Response<TrafficFlowSegmentData>> getTrafficFlowSegmentWithResponse(TrafficFlowSegmentOptions options) __Traffic Flow Segment__System.out.println("Get Traffic Flow Segment:"); // options asyncClient.getTrafficFlowSegment( new TrafficFlowSegmentOptions() .setTrafficFlowSegmentStyle(TrafficFlowSegmentStyle.ABSOLUTE).setZoom(10) .setCoordinates(new GeoPosition(4.84239, 52.41072))); // complete asyncClient.getTrafficFlowSegment( new TrafficFlowSegmentOptions() .setTrafficFlowSegmentStyle(TrafficFlowSegmentStyle.ABSOLUTE).setZoom(10) .setCoordinates(new GeoPosition(4.84239, 52.41072)).setOpenLr(false) .setThickness(2).setUnit(SpeedUnit.MPH));
**Applies to**: S0 and S1 pricing tiers.
This service provides information about the speeds and travel times of the road fragment closest to the given coordinates. It is designed to work alongside the Flow layer of the Render Service to support clickable flow data visualizations. With this API, the client side can connect any place in the map with flow data on the closest road and present it to the user.
- Parameters:
options
-TrafficFlowSegmentOptions
the options to be used in this search.- Returns:
- this object is returned from a successful Traffic Flow Segment call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.traffic.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getTrafficIncidentTile
public Mono<com.azure.core.util.BinaryData> getTrafficIncidentTile(TrafficIncidentTileOptions options) __Traffic Incident Tile__System.out.println("Get Traffic Incident Tile:"); // options client.getTrafficIncidentTile( new TrafficIncidentTileOptions() .setFormat(TileFormat.PNG).setTrafficIncidentTileStyle(TrafficIncidentTileStyle.S3) .setZoom(10)); // complete client.getTrafficIncidentTile( new TrafficIncidentTileOptions() .setFormat(TileFormat.PNG).setTrafficIncidentTileStyle(TrafficIncidentTileStyle.S3) .setZoom(10).setTileIndex(new TileIndex().setX(175).setY(408)));
**Applies to**: S0 and S1 pricing tiers.
This service serves 256 x 256 pixel tiles showing traffic incidents. All tiles use the same grid system. Because the traffic tiles use transparent images, they can be layered on top of map tiles to create a compound display. Traffic tiles render graphics to indicate traffic on the roads in the specified area.
- Parameters:
options
-TrafficIncidentTileOptions
the options to be used in this search.- Returns:
- the response.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.traffic.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getTrafficIncidentTileWithResponse
public Mono<com.azure.core.http.rest.Response<com.azure.core.util.BinaryData>> getTrafficIncidentTileWithResponse(TrafficIncidentTileOptions options) __Traffic Incident Tile__System.out.println("Get Traffic Incident Tile:"); // options client.getTrafficIncidentTile( new TrafficIncidentTileOptions() .setFormat(TileFormat.PNG).setTrafficIncidentTileStyle(TrafficIncidentTileStyle.S3) .setZoom(10)); // complete client.getTrafficIncidentTile( new TrafficIncidentTileOptions() .setFormat(TileFormat.PNG).setTrafficIncidentTileStyle(TrafficIncidentTileStyle.S3) .setZoom(10).setTileIndex(new TileIndex().setX(175).setY(408)));
**Applies to**: S0 and S1 pricing tiers.
This service serves 256 x 256 pixel tiles showing traffic incidents. All tiles use the same grid system. Because the traffic tiles use transparent images, they can be layered on top of map tiles to create a compound display. Traffic tiles render graphics to indicate traffic on the roads in the specified area.
- Parameters:
options
-TrafficIncidentTileOptions
the options to be used in this search.- Returns:
- the response.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.traffic.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getTrafficIncidentDetail
__Traffic Incident Detail__System.out.println("Get Traffic Incident Detail:"); // options client.getTrafficIncidentDetail( new TrafficIncidentDetailOptions() .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45)).setBoundingZoom(11) .setIncidentDetailStyle(IncidentDetailStyle.S3).setBoundingZoom(11) .setTrafficmodelId("1335294634919")); // complete client.getTrafficIncidentDetail( new TrafficIncidentDetailOptions() .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45)).setBoundingZoom(11) .setIncidentDetailStyle(IncidentDetailStyle.S3).setBoundingZoom(11) .setTrafficmodelId("1335294634919").setLanguage("en") .setProjectionStandard(ProjectionStandard.EPSG900913).setIncidentGeometryType(IncidentGeometryType.ORIGINAL) .setExpandCluster(false).setOriginalPosition(false));
**Applies to**: S0 and S1 pricing tiers.
This API provides information on traffic incidents inside a given bounding box, based on the current Traffic Model ID. The Traffic Model ID is available to grant synchronization of data between calls and API's. The Traffic Model ID is a key value for determining the currency of traffic incidents. It is updated every minute, and is valid for two minutes before it times out. It is used in rendering [incident tiles](https://docs.microsoft.com/rest/api/maps/traffic/gettrafficincidenttile). It can be obtained from the [Viewport API](https://docs.microsoft.com/rest/api/maps/traffic/gettrafficincidentviewport).
- Parameters:
options
-TrafficIncidentDetailOptions
the options to be used in this search.- Returns:
- this object is returned from a successful Traffic incident Detail call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.traffic.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getTrafficIncidentDetailWithResponse
public Mono<com.azure.core.http.rest.Response<TrafficIncidentDetail>> getTrafficIncidentDetailWithResponse(TrafficIncidentDetailOptions options) __Traffic Incident Detail__System.out.println("Get Traffic Incident Detail:"); // options client.getTrafficIncidentDetail( new TrafficIncidentDetailOptions() .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45)).setBoundingZoom(11) .setIncidentDetailStyle(IncidentDetailStyle.S3).setBoundingZoom(11) .setTrafficmodelId("1335294634919")); // complete client.getTrafficIncidentDetail( new TrafficIncidentDetailOptions() .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45)).setBoundingZoom(11) .setIncidentDetailStyle(IncidentDetailStyle.S3).setBoundingZoom(11) .setTrafficmodelId("1335294634919").setLanguage("en") .setProjectionStandard(ProjectionStandard.EPSG900913).setIncidentGeometryType(IncidentGeometryType.ORIGINAL) .setExpandCluster(false).setOriginalPosition(false));
**Applies to**: S0 and S1 pricing tiers.
This API provides information on traffic incidents inside a given bounding box, based on the current Traffic Model ID. The Traffic Model ID is available to grant synchronization of data between calls and API's. The Traffic Model ID is a key value for determining the currency of traffic incidents. It is updated every minute, and is valid for two minutes before it times out. It is used in rendering [incident tiles](https://docs.microsoft.com/rest/api/maps/traffic/gettrafficincidenttile). It can be obtained from the [Viewport API](https://docs.microsoft.com/rest/api/maps/traffic/gettrafficincidentviewport).
- Parameters:
options
-TrafficIncidentDetailOptions
the options to be used in this search.- Returns:
- this object is returned from a successful Traffic incident Detail call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.traffic.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getTrafficIncidentViewport
public Mono<TrafficIncidentViewport> getTrafficIncidentViewport(TrafficIncidentViewportOptions options) __Traffic Incident Viewport__System.out.println("Get Traffic Incident Tile:"); // options client.getTrafficIncidentViewport( new TrafficIncidentViewportOptions() .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45)) .setBoundingZoom(2).setOverview(new GeoBoundingBox(45, 45, 45, 45)) .setOverviewZoom(2)); // complete client.getTrafficIncidentViewport( new TrafficIncidentViewportOptions() .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45)) .setBoundingZoom(2).setOverview(new GeoBoundingBox(45, 45, 45, 45)) .setOverviewZoom(2).setCopyright(true));
**Applies to**: S0 and S1 pricing tiers.
This API returns legal and technical information for the viewport described in the request. It should be called by client applications whenever the viewport changes (for instance, through zooming, panning, going to a location, or displaying a route). The request should contain the bounding box and zoom level of the viewport whose information is needed. The return will contain map version information, as well as the current Traffic Model ID and copyright IDs. The Traffic Model ID returned by the Viewport Description is used by other APIs to retrieve last traffic information for further processing.
- Parameters:
options
-TrafficIncidentViewportOptions
the options to be used in this search.- Returns:
- this object is returned from a successful Traffic Incident Viewport call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.traffic.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-
getTrafficIncidentViewportWithResponse
public Mono<com.azure.core.http.rest.Response<TrafficIncidentViewport>> getTrafficIncidentViewportWithResponse(TrafficIncidentViewportOptions options) __Traffic Incident Viewport__System.out.println("Get Traffic Incident Tile:"); // options client.getTrafficIncidentViewport( new TrafficIncidentViewportOptions() .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45)) .setBoundingZoom(2).setOverview(new GeoBoundingBox(45, 45, 45, 45)) .setOverviewZoom(2)); // complete client.getTrafficIncidentViewport( new TrafficIncidentViewportOptions() .setBoundingBox(new GeoBoundingBox(45, 45, 45, 45)) .setBoundingZoom(2).setOverview(new GeoBoundingBox(45, 45, 45, 45)) .setOverviewZoom(2).setCopyright(true));
**Applies to**: S0 and S1 pricing tiers.
This API returns legal and technical information for the viewport described in the request. It should be called by client applications whenever the viewport changes (for instance, through zooming, panning, going to a location, or displaying a route). The request should contain the bounding box and zoom level of the viewport whose information is needed. The return will contain map version information, as well as the current Traffic Model ID and copyright IDs. The Traffic Model ID returned by the Viewport Description is used by other APIs to retrieve last traffic information for further processing.
- Parameters:
options
-TrafficIncidentViewportOptions
the options to be used in this search.- Returns:
- this object is returned from a successful Traffic Incident Viewport call.
- Throws:
IllegalArgumentException
- thrown if parameters fail the validation.com.azure.maps.traffic.implementation.models.ErrorResponseException
- thrown if the request is rejected by server.RuntimeException
- all other wrapped checked exceptions if the request fails to be sent.
-