Go Back   Android Forums > Android Development > Application Development
Application Development Dev lounge for our application developers.

New Forums: Nexus Player | Nexus 9
test: Reply
 
LinkBack Thread Tools
Old September 8th, 2011, 06:28 AM   #1 (permalink)
Junior Member
Thread Author (OP)
 
Join Date: Jul 2011
Posts: 27
 
Device(s):
Carrier: Not Provided

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

Advertisements
Arthur Andy is offline  
Reply With Quote
sponsored links
Old September 12th, 2011, 08:40 AM   #2 (permalink)
Over Macho Grande?
 
alostpacket's Avatar
 
Join Date: Nov 2009
Location: NY
Posts: 7,931
 
Device(s): Moto360, GlassXE, MotoX, MotoX'14, N5, N4, N7'12, GNex, N1, SGT10.1, Revue, Xoom, Eris, OG Droid
Carrier: TMO

Thanks: 4,611
Thanked 3,585 Times in 1,530 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
Thread Author (OP)
 
Join Date: Jul 2011
Posts: 27
 
Device(s):
Carrier: Not Provided

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)
Old July 4th, 2012, 12:53 AM   #4 (permalink)
New Member
 
Join Date: Jul 2012
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Default

it gives exception of "Service is not available". how to solve it ?
Rushil is offline  
Reply With Quote
Old July 4th, 2012, 08:13 AM   #5 (permalink)
Senior Member
 
jonbonazza's Avatar
 
Join Date: Jul 2010
Gender: Male
Posts: 1,935
 
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 482 Times in 294 Posts
Default

You need to ensure a few things first:

1) the manifest has coarse location permission (and optionally fine location as well)
2) the device has location enabled (coarse--wifi-- should be sufficient, but you can turn on fine--GPS--if you wish as well).
jonbonazza is offline  
Reply With Quote
Old July 5th, 2012, 09:09 AM   #6 (permalink)
New Member
 
Join Date: Jul 2012
Posts: 4
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Default

Hi,
I have question. Are you working with googlemaps api? I am working on that and I need some help in that. See the thread I posted and can you suggest me something if have one.
Thanks,
chanukya
chanukya4528 is offline  
Reply With Quote
Old July 6th, 2012, 06:40 AM   #7 (permalink)
Senior Member
 
jonbonazza's Avatar
 
Join Date: Jul 2010
Gender: Male
Posts: 1,935
 
Device(s): Nexus 4, Samsung Galaxy S II, HTC Evo 4G, Amazon Kindle Fire
Carrier: ATT

Thanks: 235
Thanked 482 Times in 294 Posts
Default

I use this web tool:
Ruby Geocoder

Also, if it's a famous city, you can quickly check it here:
Latitude and Longitude of World Cities (London, L.A., Paris, Singapore) &mdash; Infoplease.com
jonbonazza is offline  
Reply With Quote
Old October 1st, 2012, 01:15 PM   #8 (permalink)
New Member
 
Join Date: Oct 2012
Posts: 1
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Post Help me

Actually i have new in android so i can't find the way...
I want to do this when i enter the name of the address in android Edittext then automatically the position will show in the google map..
<EditText
android:id="@+id/source"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="Source Address"
android:inputType="textPostalAddress" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Search"
androidnClick="doClick"/>
that is the edittext in android xml....
public void doClick(Context context,Location loc)
{
MapView mapView = (MapView) findViewById(R.id.mapView);
mapView.setBuiltInZoomControls(true);
EditText editText = (EditText) findViewById(R.id.source);
List<Address> message = (List<Address>)editText.getText();
double latitude;
double longitude;
loc.getLatitude();
loc.getLongitude();
latitude=loc.getLatitude();
longitude=loc.getLongitude();
Geocoder gc = new Geocoder(this,Locale.getDefault());
try {
message = gc.getFromLocation(latitude,longitude,1);
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
MapController mc = mapView.getController();
GeoPoint geoPoint = new GeoPoint((int)(latitude * 1E6), (int)(longitude * 1E6));
mc.animateTo(geoPoint);
mc.setZoom(15);
mapView.invalidate();
}
that is my code in Activity....
plz help me...or giving me the code by which i can get my point
Joydip is offline  
Reply With Quote
Reply
Tags
android, java


Go Back   Android Forums > Android Development > Application Development
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:24 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.