MapsSearchClient Class
- java.
lang. Object - com.
azure. maps. search. MapsSearchClient
- com.
public final class MapsSearchClient
MapsSearchClient instances are created via the MapsSearchClientBuilder, as shown below. Creating a sync client using a AzureKeyCredential:
// Authenticates using subscription key
AzureKeyCredential keyCredential = new AzureKeyCredential(System.getenv("SUBSCRIPTION_KEY"));
// Creates a builder
MapsSearchClientBuilder builder = new MapsSearchClientBuilder();
builder.credential(keyCredential);
builder.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS));
// Builds the client
MapsSearchClient client = builder.buildClient();
Method Summary
Methods inherited from java.lang.Object
Method Details
getGeocoding
public GeocodingResponse getGeocoding(BaseSearchOptions options)
Use to get longitude and latitude coordinates of a street address or name of a place. The `Get Geocoding` API is an HTTP `GET` request that returns the longitude and latitude coordinates of the location being searched. In many cases, the complete search service might be too much, for instance if you are only interested in traditional geocoding. Search can also be accessed for address look up exclusively. The geocoding is performed by hitting the geocoding endpoint with just the address or partial address in question. The geocoding search index will be queried for everything above the street level data. No Point of Interest (POIs) will be returned. Note that the geocoder is very tolerant of typos and incomplete addresses. It will also handle everything from exact street addresses or street or intersections as well as higher level geographies such as city centers, counties and states. The response also returns detailed address properties such as street, postal code, municipality, and country/region information.
Parameters:
Returns:
getGeocodingBatch
public GeocodingBatchResponse getGeocodingBatch(GeocodingBatchRequestBody body)
Use to send a batch of queries to the [Geocoding](/rest/api/maps/search/get-geocoding) API in a single request. The `Get Geocoding Batch` API is an HTTP `POST` request that sends batches of up to **100** queries to the [Geocoding](/rest/api/maps/search/get-geocoding) API in a single request. ### Submit Synchronous Batch Request The Synchronous API is recommended for lightweight batch requests. When the service receives a request, it will respond as soon as the batch items are calculated and there will be no possibility to retrieve the results later. The Synchronous API will return a timeout error (a 408 response) if the request takes longer than 60 seconds. The number of batch items is limited to **100** for this API. ``` POST https://atlas.microsoft.com/geocode:batch?api-version=2023-06-01 ``` ### POST Body for Batch Request To send the _geocoding_ queries you will use a `POST` request where the request body will contain the `batchItems` array in `json` format and the `Content-Type` header will be set to `application/json`. Here's a sample request body containing 2 _geocoding_ queries: ``` { "batchItems": [ { "addressLine": "One, Microsoft Way, Redmond, WA 98052", "top": 2 }, { "addressLine": "Pike Pl", "adminDistrict": "WA", "locality": "Seattle", "top": 3 } ] } ``` A _geocoding_ batchItem object can accept any of the supported _geocoding_ [URI parameters](/rest/api/maps/search/get-geocoding#uri-parameters). The batch should contain at least **1** query. ### Batch Response Model The batch response contains a `summary` component that indicates the `totalRequests` that were part of the original batch request and `successfulRequests` i.e. queries which were executed successfully. The batch response also includes a `batchItems` array which contains a response for each and every query in the batch request. The `batchItems` will contain the results in the exact same order the original queries were sent in the batch request. Each item is of one of the following types: - [`GeocodingResponse`](/rest/api/maps/search/get-geocoding#geocodingresponse) - If the query completed successfully. - `Error` - If the query failed. The response will contain a `code` and a `message` in this case.
Parameters:
Returns:
getGeocodingBatchWithResponse
public Response<GeocodingBatchResponse> getGeocodingBatchWithResponse(GeocodingBatchRequestBody body, Context context)
Use to send a batch of queries to the [Geocoding](/rest/api/maps/search/get-geocoding) API in a single request. The `Get Geocoding Batch` API is an HTTP `POST` request that sends batches of up to **100** queries to the [Geocoding](/rest/api/maps/search/get-geocoding) API in a single request. ### Submit Synchronous Batch Request The Synchronous API is recommended for lightweight batch requests. When the service receives a request, it will respond as soon as the batch items are calculated and there will be no possibility to retrieve the results later. The Synchronous API will return a timeout error (a 408 response) if the request takes longer than 60 seconds. The number of batch items is limited to **100** for this API. ``` POST https://atlas.microsoft.com/geocode:batch?api-version=2023-06-01 ``` ### POST Body for Batch Request To send the _geocoding_ queries you will use a `POST` request where the request body will contain the `batchItems` array in `json` format and the `Content-Type` header will be set to `application/json`. Here's a sample request body containing 2 _geocoding_ queries: ``` { "batchItems": [ { "addressLine": "One, Microsoft Way, Redmond, WA 98052", "top": 2 }, { "addressLine": "Pike Pl", "adminDistrict": "WA", "locality": "Seattle", "top": 3 } ] } ``` A _geocoding_ batchItem object can accept any of the supported _geocoding_ [URI parameters](/rest/api/maps/search/get-geocoding#uri-parameters). The batch should contain at least **1** query. ### Batch Response Model The batch response contains a `summary` component that indicates the `totalRequests` that were part of the original batch request and `successfulRequests` i.e. queries which were executed successfully. The batch response also includes a `batchItems` array which contains a response for each and every query in the batch request. The `batchItems` will contain the results in the exact same order the original queries were sent in the batch request. Each item is of one of the following types: - [`GeocodingResponse`](/rest/api/maps/search/get-geocoding#geocodingresponse) - If the query completed successfully. - `Error` - If the query failed. The response will contain a `code` and a `message` in this case.
Parameters:
Returns:
getGeocodingNoCustomHeaderWithResponse
public Response<GeocodingResponse> getGeocodingNoCustomHeaderWithResponse(BaseSearchOptions options, Context context)
Use to get longitude and latitude coordinates of a street address or name of a place. The `Get Geocoding` API is an HTTP `GET` request that returns the longitude and latitude coordinates of the location being searched. In many cases, the complete search service might be too much, for instance if you are only interested in traditional geocoding. Search can also be accessed for address look up exclusively. The geocoding is performed by hitting the geocoding endpoint with just the address or partial address in question. The geocoding search index will be queried for everything above the street level data. No Point of Interest (POIs) will be returned. Note that the geocoder is very tolerant of typos and incomplete addresses. It will also handle everything from exact street addresses or street or intersections as well as higher level geographies such as city centers, counties and states. The response also returns detailed address properties such as street, postal code, municipality, and country/region information.
Parameters:
Returns:
getGeocodingWithBaseResponse
public ResponseBase<SearchesGetGeocodingHeaders,GeocodingResponse> getGeocodingWithBaseResponse(BaseSearchOptions options, Context context)
Use to get longitude and latitude coordinates of a street address or name of a place. The `Get Geocoding` API is an HTTP `GET` request that returns the longitude and latitude coordinates of the location being searched. In many cases, the complete search service might be too much, for instance if you are only interested in traditional geocoding. Search can also be accessed for address look up exclusively. The geocoding is performed by hitting the geocoding endpoint with just the address or partial address in question. The geocoding search index will be queried for everything above the street level data. No Point of Interest (POIs) will be returned. Note that the geocoder is very tolerant of typos and incomplete addresses. It will also handle everything from exact street addresses or street or intersections as well as higher level geographies such as city centers, counties and states. The response also returns detailed address properties such as street, postal code, municipality, and country/region information.
Parameters:
Returns:
getPolygons
public Boundary getPolygons(GeoPosition coordinates, String view, BoundaryResultTypeEnum resultType, ResolutionEnum resolution)
Use to get polygon data of a geographical area shape such as a city or a country region. The `Get Polygon` API is an HTTP `GET` request that supplies polygon data of a geographical area outline such as a city or a country region.
Parameters:
countryRegion result type.
Returns:
GeoJSON GeocodingFeature object that describe the boundaries of a geographical area.getPolygonsWithResponse
public Response<Boundary> getPolygonsWithResponse(GeoPosition coordinates, String view, BoundaryResultTypeEnum resultType, ResolutionEnum resolution, Context context)
Use to get polygon data of a geographical area shape such as a city or a country region. The `Get Polygon` API is an HTTP `GET` request that supplies polygon data of a geographical area outline such as a city or a country region.
Parameters:
countryRegion result type.
Returns:
GeoJSON GeocodingFeature object that describe the boundaries of a geographical area along with
Response<T>.getReverseGeocoding
public GeocodingResponse getReverseGeocoding(GeoPosition coordinates, List<ReverseGeocodingResultTypeEnum> resultTypes, String view)
Use to get a street address and location info from longitude and latitude coordinates. The `Get Reverse Geocoding` API is an HTTP `GET` request used to translate a coordinate (example: 37.786505, -122.3862) into a human understandable street address. Useful in tracking applications where you receive a GPS feed from the device or asset and wish to know the address associated with the coordinates. This endpoint will return address information for a given coordinate.
Parameters:
- Address
- Neighborhood
- PopulatedPlace
- Postcode1
- AdminDivision1
- AdminDivision2
- CountryRegion
Returns:
getReverseGeocodingBatch
public GeocodingBatchResponse getReverseGeocodingBatch(ReverseGeocodingBatchRequestBody reverseGeocodingBatchRequestBody)
Use to send a batch of queries to the [Reverse Geocoding](/rest/api/maps/search/get-reverse-geocoding) API in a single request. The `Get Reverse Geocoding Batch` API is an HTTP `POST` request that sends batches of up to **100** queries to [Reverse Geocoding](/rest/api/maps/search/get-reverse-geocoding) API using a single request. ### Submit Synchronous Batch Request The Synchronous API is recommended for lightweight batch requests. When the service receives a request, it will respond as soon as the batch items are calculated and there will be no possibility to retrieve the results later. The Synchronous API will return a timeout error (a 408 response) if the request takes longer than 60 seconds. The number of batch items is limited to **100** for this API. ``` POST https://atlas.microsoft.com/reverseGeocode:batch?api-version=2023-06-01 ``` ### POST Body for Batch Request To send the _reverse geocoding_ queries you will use a `POST` request where the request body will contain the `batchItems` array in `json` format and the `Content-Type` header will be set to `application/json`. Here's a sample request body containing 2 _reverse geocoding_ queries: ``` { "batchItems": [ { "coordinates": [-122.128275, 47.639429], "resultTypes": ["Address", "PopulatedPlace"] }, { "coordinates": [-122.341979399674, 47.6095253501216] } ] } ``` A _reverse geocoding_ batchItem object can accept any of the supported _reverse geocoding_ [URI parameters](/rest/api/maps/search/get-reverse-geocoding#uri-parameters). The batch should contain at least **1** query. ### Batch Response Model The batch response contains a `summary` component that indicates the `totalRequests` that were part of the original batch request and `successfulRequests` i.e. queries which were executed successfully. The batch response also includes a `batchItems` array which contains a response for each and every query in the batch request. The `batchItems` will contain the results in the exact same order the original queries were sent in the batch request. Each item is of one of the following types: - [`GeocodingResponse`](/rest/api/maps/search/get-reverse-geocoding#geocodingresponse) - If the query completed successfully. - `Error` - If the query failed. The response will contain a `code` and a `message` in this case.
Parameters:
Returns:
getReverseGeocodingBatchWithResponse
public Response<GeocodingBatchResponse> getReverseGeocodingBatchWithResponse(ReverseGeocodingBatchRequestBody reverseGeocodingBatchRequestBody, Context context)
Use to send a batch of queries to the [Reverse Geocoding](/rest/api/maps/search/get-reverse-geocoding) API in a single request. The `Get Reverse Geocoding Batch` API is an HTTP `POST` request that sends batches of up to **100** queries to [Reverse Geocoding](/rest/api/maps/search/get-reverse-geocoding) API using a single request. ### Submit Synchronous Batch Request The Synchronous API is recommended for lightweight batch requests. When the service receives a request, it will respond as soon as the batch items are calculated and there will be no possibility to retrieve the results later. The Synchronous API will return a timeout error (a 408 response) if the request takes longer than 60 seconds. The number of batch items is limited to **100** for this API. ``` POST https://atlas.microsoft.com/reverseGeocode:batch?api-version=2023-06-01 ``` ### POST Body for Batch Request To send the _reverse geocoding_ queries you will use a `POST` request where the request body will contain the `batchItems` array in `json` format and the `Content-Type` header will be set to `application/json`. Here's a sample request body containing 2 _reverse geocoding_ queries: ``` { "batchItems": [ { "coordinates": [-122.128275, 47.639429], "resultTypes": ["Address", "PopulatedPlace"] }, { "coordinates": [-122.341979399674, 47.6095253501216] } ] } ``` A _reverse geocoding_ batchItem object can accept any of the supported _reverse geocoding_ [URI parameters](/rest/api/maps/search/get-reverse-geocoding#uri-parameters). The batch should contain at least **1** query. ### Batch Response Model The batch response contains a `summary` component that indicates the `totalRequests` that were part of the original batch request and `successfulRequests` i.e. queries which were executed successfully. The batch response also includes a `batchItems` array which contains a response for each and every query in the batch request. The `batchItems` will contain the results in the exact same order the original queries were sent in the batch request. Each item is of one of the following types: - [`GeocodingResponse`](/rest/api/maps/search/get-reverse-geocoding#geocodingresponse) - If the query completed successfully. - `Error` - If the query failed. The response will contain a `code` and a `message` in this case.
Parameters:
Returns:
getReverseGeocodingWithResponse
public Response<GeocodingResponse> getReverseGeocodingWithResponse(GeoPosition coordinates, List<ReverseGeocodingResultTypeEnum> resultTypes, String view, Context context)
Use to get a street address and location info from longitude and latitude coordinates. The `Get Reverse Geocoding` API is an HTTP `GET` request used to translate a coordinate (example: 37.786505, -122.3862) into a human understandable street address. Useful in tracking applications where you receive a GPS feed from the device or asset and wish to know the address associated with the coordinates. This endpoint will return address information for a given coordinate.
Parameters:
- Address
- Neighborhood
- PopulatedPlace
- Postcode1
- AdminDivision1
- AdminDivision2
- CountryRegion
Returns: