Soru & Cevap

adres bulma geocoder ...

22.07.2014 - 05:03

merhabalar  bulundugum yerin lat ve long mevcut bunları kullanarak sokak sehir ülke bilgilerini elde etmek istiyorum geocoder la denedim program hatasız calıstıgı halde adresi vermiyor bunla ilgili elinizde örnek warmı 

219 Görüntülenme

4 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user gokhngungor
gokhngungor
22.07.2014 - 09:34

selam arkadaslar yine aynı olay patlamıyor catch e dusmuyor ama değeri yazmıyor  harita kullanmadığım için olabilirmi  

public void updateWithNewLocation(Location location) { 
            locationListener = new android.location.LocationListener() {
        @Override
        public void onLocationChanged(Location location) {
            // TODO Auto-generated method stub
    
            lat = location.getLatitude();
            lng = location.getLongitude();
            textView1.setText(""+lat);
            textView3.setText(""+lng);
            Log.e("lat : ", "" + lat);
            Log.e("lng : ", "" + lng);
            

               String addressString = null;
                 
                Geocoder  geoCoder = new Geocoder(getApplicationContext(), Locale.getDefault());    
                  
               try {
                   List<Address> addresses = geoCoder.getFromLocation(lat,lng, 1);
                   if (addresses.size() == 1) {
                       addressString = "";
                       Address address = addresses.get(0);
                       for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {
                           addressString += address.getAddressLine(i);
                           textAdress.setText(addressString );
                           Log.e("ADRESSSS", addressString );
                       }
                       
                   }
               } catch (IOException e) {

                   Log.e("ADRESSSS", e.getMessage() );
                  
               }

             
        }
        @Override
        public void onProviderDisabled(String provider) {
            // TODO Auto-generated method stub
            
        }
        @Override
        public void onProviderEnabled(String provider) {
            // TODO Auto-generated method stub
            
        }
        @Override
        public void onStatusChanged(String provider, int status, Bundle extras) {
            // TODO Auto-generated method stub
            
        }
            };

picture-1372-1408467635.jpg
ahmtbrk
22.07.2014 - 08:04

[code]

public String mGetAddress(Context context, double latitude, double longitude) {
        String addressString = null;
        geoCoder = new Geocoder(context, Locale.getDefault());
        try {
            List<Address> addresses = geoCoder.getFromLocation(latitude,
                    longitude, 1);
            if (addresses.size() == 1) {
                addressString = "";
                Address address = addresses.get(0);
                for (int i = 0; i < address.getMaxAddressLineIndex(); i++) {
                    addressString += address.getAddressLine(i);
                }
            }
        } catch (IOException e) {

        }
        return addressString;
    }

[/code]

methoduna enlem boylamı vererek bulabilirsin.

Profile picture for user gokhngungor
gokhngungor
22.07.2014 - 07:49

hemen deniyorum cok tesekkurler :)

picture-1784-1379605884.jpg
barkin.kizilkaya
22.07.2014 - 05:35
LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); String provider = locationManager.getBestProvider(new Criteria(), true); Location locations = locationManager.getLastKnownLocation(provider); List providerList = locationManager.getAllProviders(); if(null!=locations && null!=providerList && providerList.size()>0){ double longitude = locations.getLongitude(); double latitude = locations.getLatitude(); Geocoder geocoder = new Geocoder(getApplicationContext(), Locale.getDefault()); try { List listAddresses = geocoder.getFromLocation(latitude, longitude, 1); if(null!=listAddresses&&listAddresses.size()>0){ String _Location = listAddresses.get(0).getAddressLine(0); } } catch (IOException e) { e.printStackTrace(); } } Bu kod isini gorecektir :)