0

Hello mighty developers,

I am coding an android application to send a request to a taxi.

I've already got Android Maps API v2 setup and the map fragment is working fine.

I need to code a text field for the "From" address and another one for the "To" address

I need to be able to enter the address via text or post code and then the app will give me the option to choose the most accurate address from the choices, I also want to be able to retreive the current location of the mobile into the text field via GPS and via Network provider. Finally, I need to be able to fine tune the location chosen using a marker on the map fragment.

How on android earth can I do that ?

Im developing on Android API 8 Froyo btw as I need the app to be compatible with the most android phones possible.

Cheerio, all you cool coders

a lost developer

Mohamed Heiba
  • 1,813
  • 4
  • 38
  • 67

1 Answers1

1

What have you already tried?

The "hardest" part might be verifying the address they enter... but there are some APIs which make this pretty easy. I work at SmartyStreets, and LiveAddress API is one such service you could use. A simple HTTPS request can provide to you a list of suggested/candidate addresses. For example:

https://api.smartystreets.com/street-address?street=1600+amphitheatre+parkway&city=mtn+view&state=ca&zipcode=&auth-id=<your auth ID>&auth-token=<your API key>

The result would be:

[
    {
        "input_index":0,
        "candidate_index":0,
        "delivery_line_1":"1600 Amphitheatre Pkwy",
        "last_line":"Mountain View CA 94043-1351",
        "delivery_point_barcode":"940431351000",
        "components":
        {
            "primary_number":"1600",
            "street_name":"Amphitheatre",
            "street_suffix":"Pkwy",
            "city_name":"Mountain View",
            "state_abbreviation":"CA",
            "zipcode":"94043",
            "plus4_code":"1351",
            "delivery_point":"00",
            "delivery_point_check_digit":"0"
        },
        "metadata":
        {
            "record_type":"S",
            "county_fips":"06085",
            "county_name":"Santa Clara",
            "carrier_route":"C058",
            "congressional_district":"14",
            "rdi": "Commercial",
            "latitude": 37.41907,
            "longitude": -122.07764,
            "precision": "Zip7"
        },
        "analysis":
        {
            "dpv_match_code":"Y",
            "dpv_footnotes":"AABB",
            "dpv_cmra":"N",
            "dpv_vacant":"N",
            "ews_match":false,
            "footnotes":"B#N#"
        }
    }
]

If the address is ambiguous, a few options will be returned which you can show to the user so he/she can choose one of them.

And you mentioned ZIP codes: there's a SmartyStreets endpoint to validate ZIP codes and cities/states too.

For displaying a marker on the map, the Google Maps API has functions available for this.

Matt
  • 22,721
  • 17
  • 71
  • 112
  • I have just created an Address Textfield in the layout but it didn't do much. Thanks a lot for your answer – Mohamed Heiba Feb 11 '13 at 20:49
  • I want UK addresses so I'm gonna use the API from postcodeanywhere http://www.postcodeanywhere.co.uk/support/webservices/PostcodeAnywhere/Interactive/Find/v1.1/default.aspx I still require help with having both GPS and network providing find my location – Mohamed Heiba Feb 12 '13 at 11:18
  • @Dv_MH SmartyStreets now offers international address verification services in case you are interested – camiblanch Aug 12 '15 at 16:57