Football Fans: Download the 2012 Schedule App from Google Play!


Go Back   Android Forums > Android Development > Application Development

Application Development Dev Lounge for the Coder Folks



Reply
 
LinkBack Thread Tools
Old September 8th, 2011, 06:28 AM   #1 (permalink)
Junior Member
 
Join Date: Jul 2011
Posts: 27
 
Device(s):
Thanks: 9
Thanked 2 Times in 2 Posts
Unhappy How to find Latitude and Longitude of the given address or City name ?

Hi,
Can u tell me how to get Latitude and Longitude of the given Name of the City or Address?

For Example :

Suppose, I enter Delhi, then It should return latitude or Longitude of it.


Thanks and Regards,
Andy

Arthur Andy is offline  
Reply With Quote
Sponsors
Old September 12th, 2011, 08:40 AM   #2 (permalink)
Over Macho Grande?
 
alostpacket's Avatar
 
Join Date: Nov 2009
Location: NY
Posts: 7,090
 
Device(s): GalaxyNexus(LTE), NexusOne, OG Droid, GalaxyTab 10.1(LTE), Eris, Logitech Revue (fishtank)
Thanks: 4,164
Thanked 3,126 Times in 1,292 Posts
Default

I dont know the answer to this but am curious myself -- could be very helpful. I wonder if there is an open source /free database out there people could use to look the info up?

If you find out the answer please let us know too
alostpacket is offline  
Reply With Quote
Old September 13th, 2011, 10:18 AM   #3 (permalink)
Junior Member
 
Join Date: Jul 2011
Posts: 27
 
Device(s):
Thanks: 9
Thanked 2 Times in 2 Posts
Default

Hi,
I got my answer, I put my answer here and I hope it will help others too.

Note: Here, pass address and will get Latitude and Longitude of that address. It is working fine for me.

searchedAddress --> Can be (city name/address/Zipcode).

================================================== ==============
public boolean getLatitudeAndLongitudeFromGoogleMapForAddress(Str ing searchedAddress){

Geocoder coder = new Geocoder(IPlant.iPlantActivity);
List<Address> address;
try {

address = coder.getFromLocationName(searchedAddress,5);
if (address == null) {
Log.d(TAG, "############Address not correct #########");
}
Address location = address.get(0);

Log.d(TAG, "Address Latitude : "+ location.getLatitude();+ "Address Longitude : "+ location.getLongitude());
return true;

}catch(Exception e){
Log.d(TAG, "MY_ERROR : ############Address Not Found");
return false;
}
}

================================================== ================


Enjoy !!!
Andy
Arthur Andy is offline  
Reply With Quote
The Following User Says Thank You to Arthur Andy For This Useful Post:
alostpacket (September 13th, 2011)
Reply

Bookmarks

Tags
android, java


Go Back   Android Forums > Android Development > Application Development User CP
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 11:45 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Custom vBulletin Skins by: Relivo