com.google.maps.model.AddressComponentType Java Examples
The following examples show how to use
com.google.maps.model.AddressComponentType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ArmeriaRequestHandler.java From curiostack with MIT License | 6 votes |
private static Gson gsonForPolicy(FieldNamingPolicy fieldNamingPolicy) { return GSONS.computeIfAbsent( fieldNamingPolicy, policy -> new GsonBuilder() .registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeAdapter()) .registerTypeAdapter(Distance.class, new DistanceAdapter()) .registerTypeAdapter(Duration.class, new DurationAdapter()) .registerTypeAdapter(Fare.class, new FareAdapter()) .registerTypeAdapter(LatLng.class, new LatLngAdapter()) .registerTypeAdapter( AddressComponentType.class, new SafeEnumAdapter<>(AddressComponentType.UNKNOWN)) .registerTypeAdapter(AddressType.class, new SafeEnumAdapter<>(AddressType.UNKNOWN)) .registerTypeAdapter(TravelMode.class, new SafeEnumAdapter<>(TravelMode.UNKNOWN)) .registerTypeAdapter( LocationType.class, new SafeEnumAdapter<>(LocationType.UNKNOWN)) .registerTypeAdapter(RatingType.class, new SafeEnumAdapter<>(RatingType.UNKNOWN)) .registerTypeAdapter(DayOfWeek.class, new DayOfWeekAdapter()) .registerTypeAdapter(PriceLevel.class, new PriceLevelAdapter()) .registerTypeAdapter(Instant.class, new InstantAdapter()) .registerTypeAdapter(LocalTime.class, new LocalTimeAdapter()) .registerTypeAdapter( GeolocationApi.Response.class, new GeolocationResponseAdapter()) .setFieldNamingPolicy(policy) .create()); }
Example #2
Source File: GeocodingApiTest.java From google-maps-services-java with Apache License 2.0 | 6 votes |
/** * Simple reverse geocoding. <a * href="https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452">Reverse * geocode (40.714224,-73.961452)</a>. */ @Test public void testSimpleReverseGeocode() throws Exception { try (LocalTestServerContext sc = new LocalTestServerContext(simpleReverseGeocodeResponse)) { LatLng latlng = new LatLng(40.714224, -73.961452); GeocodingResult[] results = GeocodingApi.newRequest(sc.context).latlng(latlng).await(); assertNotNull(results); assertNotNull(Arrays.toString(results)); assertEquals("277 Bedford Ave, Brooklyn, NY 11211, USA", results[0].formattedAddress); assertEquals("277", results[0].addressComponents[0].longName); assertEquals("277", results[0].addressComponents[0].shortName); assertEquals(AddressComponentType.STREET_NUMBER, results[0].addressComponents[0].types[0]); assertEquals(AddressType.STREET_ADDRESS, results[0].types[0]); sc.assertParamValue(latlng.toUrlValue(), "latlng"); } }
Example #3
Source File: GeocodingApiTest.java From google-maps-services-java with Apache License 2.0 | 6 votes |
/** Testing Kita Ward reverse geocode. */ @Test public void testReverseGeocodeWithKitaWard() throws Exception { try (LocalTestServerContext sc = new LocalTestServerContext(reverseGeocodeWithKitaWardResponse)) { LatLng location = new LatLng(35.03937, 135.729243); GeocodingResult[] results = GeocodingApi.newRequest(sc.context).latlng(location).await(); assertNotNull(results); assertNotNull(Arrays.toString(results)); assertEquals( "Japan, 〒603-8361 Kyōto-fu, Kyōto-shi, Kita-ku, Kinkakujichō, 1 北山鹿苑寺金閣寺", results[0].formattedAddress); assertEquals("Kita Ward", results[3].addressComponents[0].shortName); assertEquals("Kita Ward", results[3].addressComponents[0].longName); assertEquals(AddressComponentType.LOCALITY, results[3].addressComponents[0].types[0]); assertEquals(AddressComponentType.POLITICAL, results[3].addressComponents[0].types[1]); assertEquals(AddressComponentType.WARD, results[3].addressComponents[0].types[2]); sc.assertParamValue(location.toUrlValue(), "latlng"); } }