Antegeia
Antegeia

Reputation: 269

Convert street address to coordinates android

I am trying to find a way in how to convert a given street address into coordinates with Google maps in an android application. Any suggestion please or some links to read about it?

Upvotes: 4

Views: 1508

Answers (1)

jzafrilla
jzafrilla

Reputation: 1436

Try this

 Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault());
 String textToSearch = searchText.getText().toString();
 List<Address> fromLocationName = null;
 fromLocationName = geocoder.getFromLocationName(texToSearch,   1);
 if (fromLocationName != null && fromLocationName.size() > 0) {
    Address a = fromLocationName.get(0);
    GeoPoint point = new GeoPoint(
                         (int) (a.getLatitude() * _1E6), 
                         (int) (a.getLongitude() * _1E6));
 }

Upvotes: 1

Related Questions