I use this url to get addresses with Get request: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=Nov&key=MyKet&types=address
But sometimes I get only streets without houses, sometimes I get even cities (if input=Minsk in Russian: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=%D0%9C%D0%98%D0%9D%D0%A1%D0%9A&key=MyKey&types=address)
But I want to get only streets with houses, because I'm writing taxi application and I need there only full address, it's not enough if user selected only street.
So if I get from Google Proletarsk street 25, Bern, Switzerland
- it's ok, but if I get from Google Proletarsk street, Bern, Switzerland
- it's not ok.
And when I get the responce from Google for streets and addresses it always return the same type
types = (
route,
geocode
);
So I can't even differ if the return value is a street or if it's a full address.
Can you give me any advice?
Based on the use case you describe, it sounds like you used the wrong API.
You should be using the Geocoding API if you have the address and would love Google Maps parse it for you and return extra information. You can determine if the result has a street_number
so that you can tell if the result contains a full address. For example:
https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA
would give you a result like this:
{
"results" : [
{
"address_components" : [
{
"long_name" : "1600",
"short_name" : "1600",
"types" : [ "street_number" ]
},
{
"long_name" : "Amphitheatre Parkway",
"short_name" : "Amphitheatre Pkwy",
"types" : [ "route" ]
},
{
"long_name" : "Mountain View",
"short_name" : "Mountain View",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Santa Clara County",
"short_name" : "Santa Clara County",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "California",
"short_name" : "CA",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "United States",
"short_name" : "US",
"types" : [ "country", "political" ]
},
{
"long_name" : "94043",
"short_name" : "94043",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "1600 Amphitheatre Parkway, Mountain View, CA 94043, USA",
"geometry" : {
"location" : {
"lat" : 37.4223455,
"lng" : -122.0841893
},
"location_type" : "ROOFTOP",
"viewp.....
Which give you a street_number
and so you can tell it is a full address.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With