How to find all the addresses using postal code in android ? - android

When I entered a postal code in my Edittext and click on a button, I need to show a address list related to that particular postal code in a Spinner.

You need to use Geocoder class for your requirement. The thing you are asking in known as reverse-geocoding.

There is service provided by google.
http://maps.google.com/maps/api/geocode/json?address=&components=postal_code:15204&sensor=false
In the URl 15204 is the postal code. Make a call to the url with the postal code in place.
This returns a json format, parse the list of cities with the postal code.
Probably first result is what you are looking for.

Related

Postal code and Address

How to get an address based on the postal code? Which api should I call? I didn't find the answer from google map platform。
Geocoder can't get the detail address
Try this API for fetching address based on pincode.
http://maps.googleapis.com/maps/api/geocode/json?components=postal_code:90210&sensor=false
Like others pointed out, in some cases there is a one to one correspondence between an address and a post code, like in Singapore where you can use geocode.xyz to convert between them: https://geocode.xyz/508260?region=SG
For USA, you need a zip+4 postal code, for example: https://geocoder.ca/10005-1971?geoit=xml
<standard>
<stnumber>4</stnumber>
<staddress>Wall St</staddress>
<city>New York</city>
<prov>NY</prov>
<postal>10005-1971</postal>
<confidence>0.5</confidence>
</standard>

Android GeoCoder returns two different places for one adress

I am using the GeoCoder for getting lat and long coordinates by giving him street adress, post code, and country. I have only adresses for Germany.
There is a street called "Sandgrubenstraße" with its post code but he is adding a marker somewhere in Austria. But it should be added in Germany.
I found out, that there is the same street in Autria called "Sandgrubenstraße" but how does that work when I use the post code which is unique?
How can I prevent GeoCoder to add markers that are NOT in Germany? How can I restrict this behaviour ? Do you have an example?
Postcodes are not globally unique, different countries can and do have overlapping post codes and different standards. Adding the country name to geocode prevents this happening, so you should add "country" when filtering for address components.
components=country:DE should solve this.

Autocomplete text for more than one countries in google map api

I want to pick the cities for Singapore country in android editbox. So i use the place Autocomplete text by using this url,
https://maps.googleapis.com/maps/api/place/autocomplete/json?key=XXXXXXXXXXXXXXXXXX&type=(cities)&components=countries:sg&input=k.
I get the cities in singapore. But my question is, I want to get two country's cities (like Singapore and Malayasia) by using the same url.
I already tried to change the parameters like, &&components=countries:sg,my. But I get the response as INVALID_REQUEST.
Please friends, Kindly help me to solve this.I am in running short of time.
Thanks in advance
You can do it like this:
https://maps.googleapis.com/maps/api/place/autocomplete/json?key=XXXXXXXXXXXXXXXXXX&type=(cities)&components=country:es|country:uk|country:us

prioritize within city response for address using maps.googleapis

As I am typing autocomplete address using http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=** I would like to prioritize within that city any address that begins with the following name .For ex: if I type mount and priority is California then it should give back Mountain view as the recommendation answer.How do I do that .I really appreciate any help.PLease let me know with respect to the above api call.Thanks in advance.
See https://developers.google.com/maps/documentation/geocoding/#Viewports
The short of it is that you can add a 'bounds' parameter that specifies lat-lng points to hint to the geocoder that you wish to look within a particular area. An example from that page is:
http://maps.googleapis.com/maps/api/geocode/json?address=Winnetka&bounds=34.172684,-118.604794|34.236144,-118.500938&sensor=false

Seperate address name from number android

I am creating an app and i get an Address from geocoder.So I am getting a string that contains the address.My problem is that I want to put the name in a Textview the number in an Edittext(so the client can edit the number) and the city with the postcode to an other Textview.Any ideas?Thanks.
If there is a particular pattern in the Address you get, you can use String.split() method of Java to extract tokens which can then be used individually to fill particular information. See this example for understanding its working.
The best approach would be to write a Regular expression and group corresponding pieces of information and then getting them back using Matcher class.
This example explains how to get Regular expression's to work.

Categories

Resources