i am try to get latitude & longitude from address , problem is that .. when i give only city name than it give me correct latitude & longitude and when i give complete address (like state , city name , street No.) than it do not give me correct latitude & longitude ...
thanks for your cooperative response ...
my code is ..
//String addressStr = "faisalabad";/// this give me correct address
String addressStr = "Sainta Augustine,FL,4405 Avenue A";
Geocoder geoCoder = new Geocoder(MapClass.this, Locale.getDefault());
try {
List<Address> addresses =
geoCoder.getFromLocationName(addressStr, 1);
if (addresses.size() > 0) {
latitude = addresses.get(0).getLatitude(); longtitude =
addresses.get(0).getLongitude(); }
} catch (IOException e) { // TODO Auto-generated catch block
e.printStackTrace(); }
pos = new LatLng(latitude, longtitude);
googleMap.addMarker(new MarkerOptions().icon(
BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_RED))
.position(pos));
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(pos, 15));
googleMap.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
i don it ... :)
only sequence is incorrect ...
first give street address than city name and than state ... it give me correct latitude and longitude from address .. :)
and change
Geocoder geoCoder = new Geocoder(MapClass.this, Locale.getDefault());
to
Geocoder geoCoder = new Geocoder(MapClass.this);
thanks, all of you for your time ...