@@ -26,7 +26,7 @@ Various documentation is available to help you get started
2626<dependency >
2727 <groupId >com.azure</groupId >
2828 <artifactId >azure-maps-search</artifactId >
29- <version >1 .0.0-beta.1</version >
29+ <version >2 .0.0-beta.1</version >
3030</dependency >
3131```
3232[ // ] : # ( {x-version-update-end} )
@@ -73,312 +73,88 @@ See [Authentication][authenticate] for more options.
7373See [ API design] [ design ] for general introduction on design and key concepts on Azure Management Libraries.
7474
7575## Examples
76- Get Polygons
77- ``` java com.azure.maps.search.sync.get_polygon
78- SearchAddressResult results = client. fuzzySearch(
79- new FuzzySearchOptions (" 1 Microsoft Way" , new GeoPosition (- 74.011454 , 40.706270 ))
80- .setTop(5 ));
81- Response<SearchAddressResult > response = client. fuzzySearchWithResponse(
82- new FuzzySearchOptions (" Monaco" ). setEntityType(GeographicEntityType . COUNTRY )
83- .setTop(5 ), null );
84- String id = response. getValue(). getResults(). get(0 ). getDataSource(). getGeometry();
85- List<String > ids = results. getResults(). stream()
86- .filter(item - > item. getDataSource() != null && item. getDataSource(). getGeometry() != null )
87- .map(item - > item. getDataSource(). getGeometry())
88- .collect(Collectors . toList());
89- ids. add(id);
90-
91- if (ids != null && ! ids. isEmpty()) {
92- System . out. println(" Get Polygon: " + ids);
93- client. getPolygons(ids);
94- client. getPolygonsWithResponse(ids, null ). getValue(). getClass();
95- }
96- ```
97-
98- Fuzzy Search
99- ``` java com.azure.maps.search.sync.fuzzy_search
100- System . out. println(" Search Fuzzy:" );
76+ ### Get Polygons
77+ ``` java sync.get_polygon
78+ System . out. println(" Get Polygons:" );
79+ GeoPosition coordinates = new GeoPosition (- 122.204141 , 47.61256 );
10180
102- // simple
103- client. fuzzySearch(new FuzzySearchOptions (" starbucks" ));
81+ Boundary result = client. getPolygons(coordinates, null , BoundaryResultTypeEnum . LOCALITY , ResolutionEnum . SMALL );
10482
105- // with options
106- SearchAddressResult results = client. fuzzySearch(
107- new FuzzySearchOptions (" 1 Microsoft Way" , new GeoPosition (- 74.011454 , 40.706270 ))
108- .setTop(5 ));
83+ // with response
84+ Response<Boundary > response = client. getPolygonsWithResponse(coordinates, null , BoundaryResultTypeEnum . LOCALITY , ResolutionEnum . SMALL , Context . NONE );
10985
110- // with response
111- Response<SearchAddressResult > response = client. fuzzySearchWithResponse(
112- new FuzzySearchOptions (" Monaco" ). setEntityType(GeographicEntityType . COUNTRY )
113- .setTop(5 ), null );
11486```
11587
116- Search Point Of Interest
117- ``` java com.azure.maps.search. sync.get_search_poi
118- System . out. println(" Search Points of Interest :" );
88+ ### Get Geocoding
89+ ``` java sync.get_geocoding
90+ System . out. println(" Get Geocoding :" );
11991
120- // coordinates
121- client. searchPointOfInterest(
122- new SearchPointOfInterestOptions (" pizza" , new GeoPosition (- 121.97483 , 36.98844 )));
92+ // simple
93+ client. getGeocoding(new BaseSearchOptions (). setQuery(" 1 Microsoft Way, Redmond, WA 98052" ));
12394
124- // options
125- client. searchPointOfInterest(
126- new SearchPointOfInterestOptions (" pizza" , new GeoPosition (- 121.97483 , 36.98844 ))
127- .setTop(10 )
128- .setOperatingHours(OperatingHoursRange . NEXT_SEVEN_DAYS ));
95+ // with multiple options
96+ GeocodingResponse result = client. getGeocoding(
97+ new BaseSearchOptions (). setCoordinates(new GeoPosition (- 74.011454 , 40.706270 )). setTop(5 ));
12998
13099// with response
131- client. searchPointOfInterestWithResponse(
132- new SearchPointOfInterestOptions (" pizza" , new GeoPosition (- 121.97483 , 36.98844 ))
133- .setTop(10 )
134- .setOperatingHours(OperatingHoursRange . NEXT_SEVEN_DAYS ),
135- null ). getStatusCode();
136- ```
100+ ResponseBase<SearchesGetGeocodingHeaders , GeocodingResponse > response = client. getGeocodingWithBaseResponse(
101+ new BaseSearchOptions (). setCoordinates(new GeoPosition (- 74.011454 , 40.706270 )). setTop(5 ), null );
137102
138- Search Nearby Point Of Interest
139- ``` java com.azure.maps.search.sync.search_nearby
140- System . out. println(" Search Nearby Points of Interest:" );
141-
142- // options
143- client. searchNearbyPointsOfInterest(
144- new SearchNearbyPointsOfInterestOptions (new GeoPosition (- 74.011454 , 40.706270 ))
145- .setCountryFilter(Arrays . asList(" US" ))
146- .setTop(10 ));
147-
148- // response
149- client. searchNearbyPointsOfInterestWithResponse(
150- new SearchNearbyPointsOfInterestOptions (new GeoPosition (- 74.011454 , 40.706270 ))
151- .setCountryFilter(Arrays . asList(" US" ))
152- .setTop(10 ),
153- null ). getStatusCode();
103+ // with response no custom header
104+ Response<GeocodingResponse > responseNoHeader = client. getGeocodingNoCustomHeaderWithResponse(
105+ new BaseSearchOptions (). setCoordinates(new GeoPosition (- 74.011454 , 40.706270 )). setTop(5 ), null );
154106```
155107
156- Search Point Of Interest Category
157- ``` java com.azure.maps.search.sync.search_nearby
158- System . out. println(" Search Nearby Points of Interest:" );
159-
160- // options
161- client. searchNearbyPointsOfInterest(
162- new SearchNearbyPointsOfInterestOptions (new GeoPosition (- 74.011454 , 40.706270 ))
163- .setCountryFilter(Arrays . asList(" US" ))
164- .setTop(10 ));
165-
166- // response
167- client. searchNearbyPointsOfInterestWithResponse(
168- new SearchNearbyPointsOfInterestOptions (new GeoPosition (- 74.011454 , 40.706270 ))
169- .setCountryFilter(Arrays . asList(" US" ))
170- .setTop(10 ),
171- null ). getStatusCode();
172- ```
108+ ### Get Geocoding Batch
109+ ``` java sync.get_geocoding_batch
110+ System . out. println(" Get Geocoding Batch:" );
173111
174- Get Point Of Interest Category Tree
175- ``` java com.azure.maps.search.sync.search_poi_category_tree
176- System . out. println(" Get Search POI Category Tree:" );
177- client. getPointOfInterestCategoryTree();
178- ```
112+ // with multiple items
113+ GeocodingBatchRequestBody body = new GeocodingBatchRequestBody ();
114+ GeocodingBatchRequestItem addressLineItem = new GeocodingBatchRequestItem ();
115+ addressLineItem. setAddressLine(" 400 Broad St" );
116+ GeocodingBatchRequestItem queryItem = new GeocodingBatchRequestItem ();
117+ queryItem. setQuery(" 15171 NE 24th St, Redmond, WA 98052, United States" );
118+ body. setBatchItems(Arrays . asList(addressLineItem, queryItem));
179119
180- Search Address
181- ``` java com.azure.maps.search.sync.search_address
182- System . out. println(" Search Address:" );
183-
184- // simple
185- client. searchAddress(
186- new SearchAddressOptions (" 15127 NE 24th Street, Redmond, WA 98052" ));
187-
188- // options
189- client. searchAddress(
190- new SearchAddressOptions (" 1 Main Street" )
191- .setCoordinates(new GeoPosition (- 74.011454 , 40.706270 ))
192- .setRadiusInMeters(40000 )
193- .setTop(5 ));
194-
195- // complete
196- client. searchAddressWithResponse(
197- new SearchAddressOptions (" 1 Main Street" )
198- .setCoordinates(new GeoPosition (- 74.011454 , 40.706270 ))
199- .setRadiusInMeters(40000 )
200- .setTop(5 ), null ). getStatusCode();
201- ```
120+ GeocodingBatchResponse result = client. getGeocodingBatch(body);
202121
203- Reverse Search Address
204- ``` java com.azure.maps.search.sync.reverse_search_address
205- System . out. println(" Search Address Reverse:" );
206-
207- // simple
208- client. reverseSearchAddress(
209- new ReverseSearchAddressOptions (new GeoPosition (- 121.89 , 37.337 )));
210-
211- client. reverseSearchAddress(
212- new ReverseSearchAddressOptions (new GeoPosition (- 121.89 , 37.337 )));
213-
214- // options
215- client. reverseSearchAddress(
216- new ReverseSearchAddressOptions (new GeoPosition (- 121.89 , 37.337 ))
217- .setIncludeSpeedLimit(true )
218- .setEntityType(GeographicEntityType . COUNTRY_SECONDARY_SUBDIVISION ) // returns only city
219- );
220-
221- // complete
222- client. reverseSearchAddressWithResponse(
223- new ReverseSearchAddressOptions (new GeoPosition (- 121.89 , 37.337 ))
224- .setIncludeSpeedLimit(true )
225- .setEntityType(GeographicEntityType . COUNTRY_SECONDARY_SUBDIVISION ),
226- null ). getStatusCode();
227- ```
122+ // with response
123+ Response<GeocodingBatchResponse > response = client. getGeocodingBatchWithResponse(body, Context . NONE );
228124
229- Reverse Search Cross Street Address
230- ``` java com.azure.maps.search.sync.search_reverse_cross_street_address
231- System . out. println(" Revere Search Cross Street Address:" );
232-
233- // options
234- client. reverseSearchCrossStreetAddress(
235- new ReverseSearchCrossStreetAddressOptions (new GeoPosition (- 121.89 , 37.337 )));
236-
237- // options
238- client. reverseSearchCrossStreetAddress(
239- new ReverseSearchCrossStreetAddressOptions (new GeoPosition (- 121.89 , 37.337 ))
240- .setTop(2 )
241- .setHeading(5 ));
242-
243- // complete
244- client. reverseSearchCrossStreetAddressWithResponse(
245- new ReverseSearchCrossStreetAddressOptions (new GeoPosition (- 121.89 , 37.337 ))
246- .setTop(2 )
247- .setHeading(5 ),
248- null ). getStatusCode();
249125```
250126
251- Search Structured Address
252- ``` java com.azure.maps.search.sync.search_structured_address
253- System . out. println(" Search Address Structured:" );
254-
255- // simple
256- client. searchStructuredAddress(new StructuredAddress (" US" )
257- .setPostalCode(" 98121" )
258- .setStreetNumber(" 15127" )
259- .setStreetName(" NE 24th Street" )
260- .setMunicipality(" Redmond" )
261- .setCountrySubdivision(" WA" ), null );
262-
263- // complete
264- client. searchStructuredAddressWithResponse(new StructuredAddress (" US" )
265- .setPostalCode(" 98121" )
266- .setStreetNumber(" 15127" )
267- .setStreetName(" NE 24th Street" )
268- .setMunicipality(" Redmond" )
269- .setCountrySubdivision(" WA" ),
270- new SearchStructuredAddressOptions ()
271- .setTop(2 )
272- .setRadiusInMeters(1000 ),
273- null ). getStatusCode();
274- ```
127+ ### Get Reverse Geocoding
128+ ``` java sync.get_reverse_geocoding
129+ System . out. println(" Get Reverse Geocoding:" );
275130
276- Search Inside Geometry
277- ``` java com.azure.maps.search.sync.search_inside_geometry
278- System . out. println(" Search Inside Geometry" );
279-
280- // create GeoPolygon
281- List<GeoPosition > coordinates = new ArrayList<> ();
282- coordinates. add(new GeoPosition (- 122.43576049804686 , 37.7524152343544 ));
283- coordinates. add(new GeoPosition (- 122.43301391601562 , 37.70660472542312 ));
284- coordinates. add(new GeoPosition (- 122.36434936523438 , 37.712059855877314 ));
285- coordinates. add(new GeoPosition (- 122.43576049804686 , 37.7524152343544 ));
286- GeoLinearRing ring = new GeoLinearRing (coordinates);
287- GeoPolygon polygon = new GeoPolygon (ring);
288-
289- // simple
290- client. searchInsideGeometry(
291- new SearchInsideGeometryOptions (" Leland Avenue" , polygon));
292-
293- // options
294- client. searchInsideGeometry(
295- new SearchInsideGeometryOptions (" Leland Avenue" , polygon)
296- .setTop(5 ));
297-
298- // complete
299- client. searchInsideGeometryWithResponse(
300- new SearchInsideGeometryOptions (" Leland Avenue" , polygon)
301- .setTop(5 ),
302- null ). getStatusCode();
303- ```
131+ GeoPosition coordinates = new GeoPosition (- 122.34255 , 47.0 );
132+ GeocodingResponse result = client. getReverseGeocoding(coordinates, Arrays . asList(ReverseGeocodingResultTypeEnum . ADDRESS ), null );
304133
305- Search Along Route
306- ``` java com.azure.maps.search.sync.search_along_route
307- System . out. println(" Search Along Route" );
308-
309- // create route points
310- List<GeoPosition > points = new ArrayList<> ();
311- points. add(new GeoPosition (- 122.143035 , 47.653536 ));
312- points. add(new GeoPosition (- 122.187164 , 47.617556 ));
313- points. add(new GeoPosition (- 122.114981 , 47.570599 ));
314- points. add(new GeoPosition (- 122.132756 , 47.654009 ));
315- GeoLineString route = new GeoLineString (points);
316-
317- // simple
318- client. searchAlongRoute(new SearchAlongRouteOptions (" burger" , 1000 , route));
319-
320- // options
321- client. searchAlongRoute(
322- new SearchAlongRouteOptions (" burger" , 1000 , route)
323- .setCategoryFilter(Arrays . asList(7315 ))
324- .setTop(5 ));
325-
326- // complete
327- client. searchAlongRouteWithResponse(
328- new SearchAlongRouteOptions (" burger" , 1000 , route)
329- .setCategoryFilter(Arrays . asList(7315 ))
330- .setTop(5 ),
331- null ). getStatusCode();
134+ // with response
135+ Response<GeocodingResponse > response = client. getReverseGeocodingWithResponse(coordinates, Arrays . asList(ReverseGeocodingResultTypeEnum . ADDRESS ), null , Context . NONE );
332136```
333137
334- Begin Fuzzy Search Batch
335- ``` java com.azure.maps.search.sync.fuzzy_search_batch
336- List<FuzzySearchOptions > fuzzyOptionsList = new ArrayList<> ();
337- fuzzyOptionsList. add(new FuzzySearchOptions (" atm" , new GeoPosition (- 122.128362 , 47.639769 ))
338- .setRadiusInMeters(5000 ). setTop(5 ));
339- fuzzyOptionsList. add(new FuzzySearchOptions (" Statue of Liberty" ). setTop(2 ));
340- fuzzyOptionsList. add(new FuzzySearchOptions (" Starbucks" , new GeoPosition (- 122.128362 , 47.639769 ))
341- .setRadiusInMeters(5000 ));
342-
343- System . out. println(" Post Search Fuzzy Batch Async" );
344- client. beginFuzzySearchBatch(fuzzyOptionsList). getFinalResult();
345- ```
138+ ### Get Reverse Geocoding Batch
139+ ``` java sync.get_reverse_geocoding_batch
140+ System . out. println(" Get Reverse Geocoding Batch:" );
346141
347- Begin Search Address Batch
348- ``` java com.azure.maps.search.sync.search_address_batch
349- List<SearchAddressOptions > optionsList = new ArrayList<> ();
350- optionsList. add(new SearchAddressOptions (" 400 Broad St, Seattle, WA 98109" ). setTop(3 ));
351- optionsList. add(new SearchAddressOptions (" One, Microsoft Way, Redmond, WA 98052" ). setTop(3 ));
352- optionsList. add(new SearchAddressOptions (" 350 5th Ave, New York, NY 10118" ). setTop(3 ));
353- optionsList. add(new SearchAddressOptions (" 1 Main Street" )
354- .setCountryFilter(Arrays . asList(" GB" , " US" , " AU" )). setTop(3 ));
355-
356- // Search address batch async -
357- // https://docs.microsoft.com/en-us/rest/api/maps/search/post-search-address-batch
358- // This call posts addresses for search using the Asynchronous Batch API.
359- // SyncPoller will do the polling automatically and you can retrieve the result
360- // with getFinalResult()
361- System . out. println(" Search Address Batch Async" );
362- client. beginSearchAddressBatch(optionsList). getFinalResult();
363- SyncPoller<BatchSearchResult , BatchSearchResult > poller = client. beginSearchAddressBatch(optionsList);
364- BatchSearchResult result = poller. getFinalResult();
365- ```
142+ // with multiple items
143+ ReverseGeocodingBatchRequestBody body = new ReverseGeocodingBatchRequestBody ();
144+ ReverseGeocodingBatchRequestItem item1 = new ReverseGeocodingBatchRequestItem ();
145+ ReverseGeocodingBatchRequestItem item2 = new ReverseGeocodingBatchRequestItem ();
146+ item1. setCoordinates(new GeoPosition (- 122.34255 , 47.0 ));
147+ item2. setCoordinates(new GeoPosition (- 122.34255 , 47.0 ));
148+ body. setBatchItems(Arrays . asList(item1, item2));
149+
150+ GeocodingBatchResponse result = client. getReverseGeocodingBatch(body);
151+
152+ // with response
153+ Response<GeocodingBatchResponse > response = client. getReverseGeocodingBatchWithResponse(body, Context . NONE );
366154
367- Reverse Reverse Search Address Batch
368- ``` java com.azure.maps.search.sync.reverse_search_address_batch
369- List<ReverseSearchAddressOptions > reverseOptionsList = new ArrayList<> ();
370- reverseOptionsList. add(new ReverseSearchAddressOptions (new GeoPosition (2.294911 , 48.858561 )));
371- reverseOptionsList. add(
372- new ReverseSearchAddressOptions (new GeoPosition (- 122.127896 , 47.639765 ))
373- .setRadiusInMeters(5000 )
374- );
375- reverseOptionsList. add(new ReverseSearchAddressOptions (new GeoPosition (- 122.348170 , 47.621028 )));
376-
377- System . out. println(" Reverse Search Address Batch Async" );
378- BatchReverseSearchResult br1 =
379- client. beginReverseSearchAddressBatch(reverseOptionsList). getFinalResult();
380155```
381156
157+
382158## Troubleshooting
383159When you interact with the Azure Maps Services, errors returned by the Maps service correspond to the same HTTP status codes returned for REST API requests.
384160
0 commit comments