0

How to find out latitude and longitude from the address...

Here's the code for the spinner where we get the value of address

       landmark_addprod.setOnItemSelectedListener(new OnItemSelectedListener(){
        public void onItemSelected(AdapterView<?> parent, View view, int pos,long id)
        {
            // ListView Clicked item value
            itemValue_landmark = (String) landmark_addprod.getItemAtPosition(pos);
        }

and here get the value of city

            public void onItemSelected(AdapterView<?> parent, View view, int pos,long id)
            {
                itemPosition_city = pos;

                  // ListView Clicked item value
                   itemValue_city = (String) city_addprod.getItemAtPosition(pos);
            }

So how to concatenate the address and city values and how to find out lat longitude from that???

also used--

                Geocoder coder = new Geocoder(addproducts.this);
             try 
                {
            ArrayList<Address> adresses = (ArrayList<Address>) coder.getFromLocationName(itemValue_landmark + itemValue_city, 1);
            for(Address add : adresses){
                    longitude = add.getLongitude();
                    latitude = add.getLatitude();
                } 
            }
        catch (IOException e) {
                e.printStackTrace();
            }

but get the latitude and longitude 0.0

user2964797
  • 3
  • 3
  • 8

1 Answers1

0

This previous question may of use to you. Check it out here. Used this method before and it works nicely!

Community
  • 1
  • 1
Joe Birch
  • 371
  • 2
  • 7
  • also used geocoder but got the o/p of latitude longitude to 0.0 – user2964797 Dec 07 '13 at 01:57
  • is there any problem in --------------- coder.getFromLocationName(itemValue_landmark + itemValue_city, 1); – user2964797 Dec 07 '13 at 01:58
  • and one thing i want to store latitude and longitude in sql server database we are getting responce in double..so plz tell me which is data type should be used for these latitude and longitude in sql server database..thanks.. – user2964797 Dec 07 '13 at 02:45