Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6782225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:42:58+00:00 2026-05-26T16:42:58+00:00

I am building an application. In which now i am getting the map and

  • 0

I am building an application. In which now i am getting the map and also the latitude and longitude of the touched location. I also wanted the address of the touched location corresponding to the latitude and longitude. How can i achieve this?

 public class MapViewEvents extends MapActivity {

 private TextView myLongitude, myLatitude;
 String result1;
 private Context context;
 private MapView myMapView;
 private MapController myMapController;
 private double la;
 private double lo;
@Override
protected void onCreate(Bundle icicle) {
    // TODO Auto-generated method stub
    super.onCreate(icicle);
    setContentView(R.layout.mymapview);

    myMapView = (MapView)findViewById(R.id.mapview);
    myMapController = myMapView.getController();  
    myMapView.setBuiltInZoomControls(true);

    myLongitude = (TextView)findViewById(R.id.longitude);
    myLatitude = (TextView)findViewById(R.id.latitude);

        la= RoamMeo_Config.Gpslatitude;
        lo=RoamMeo_Config.Gpslongitude;

        int latitude = (int)(la * 1000000);
        int longitude = (int)(lo * 1000000);

        GeoPoint initGeoPoint = new GeoPoint(latitude, longitude);
        CenterLocation(initGeoPoint);

        Button nxt_button = (Button) findViewById(R.id.btn_next);
        nxt_button.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    //System.out.println(result1);
                    //Intent intent = new Intent(Home.this, EventList.class);
                    //startActivity(intent);
            }
        });
}

private void placeMarker(int markerLatitude, int markerLongitude)
{
    Drawable marker=getResources().getDrawable(
            android.R.drawable.ic_menu_myplaces);
    marker.setBounds(0, 0, marker.getIntrinsicWidth(), 
            marker.getIntrinsicHeight());
    myMapView.getOverlays().add(new InterestingLocations(marker, 
            markerLatitude, markerLongitude));
}

@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}

private void CenterLocation(GeoPoint centerGeoPoint)
{
    myMapController.animateTo(centerGeoPoint);

    myLongitude.setText("Longitude: "+
        String.valueOf((float)centerGeoPoint.getLongitudeE6()/1000000));
    myLatitude.setText("Latitude: "+
        String.valueOf((float)centerGeoPoint.getLatitudeE6()/1000000));
    placeMarker(centerGeoPoint.getLatitudeE6(), 
            centerGeoPoint.getLongitudeE6());
};


class InterestingLocations extends ItemizedOverlay<OverlayItem>{

    private List<OverlayItem> locations = 
        new ArrayList<OverlayItem>();
    private Drawable marker;
    private OverlayItem myOverlayItem;

    boolean MoveMap;

    public InterestingLocations(Drawable defaultMarker, 
            int LatitudeE6, int LongitudeE6) {
        super(defaultMarker);
        // TODO Auto-generated constructor stub
        this.marker=defaultMarker;
        // create locations of interest
        GeoPoint myPlace = new GeoPoint(LatitudeE6,LongitudeE6);
        myOverlayItem = new OverlayItem(myPlace, "My Place", "My Place");
        locations.add(myOverlayItem);

        populate();
    }


    @Override
    protected OverlayItem createItem(int i) {
        // TODO Auto-generated method stub
        return locations.get(i);
    }

    @Override
    public int size() {
        // TODO Auto-generated method stub
        return locations.size();
    }

    @Override
    public void draw(Canvas canvas, MapView mapView, 
            boolean shadow) {
        // TODO Auto-generated method stub
        super.draw(canvas, mapView, shadow);

        boundCenterBottom(marker);
    }

    @Override
    public boolean onTouchEvent(MotionEvent arg0, MapView arg1) {
        // TODO Auto-generated method stub
        //super.onTouchEvent(arg0, arg1);

        int Action = arg0.getAction();
        if (Action == MotionEvent.ACTION_UP){

            if(!MoveMap)
            {
                Projection proj = myMapView.getProjection(); 
                GeoPoint loc = proj.fromPixels((int)arg0.getX(), (int)arg0.getY());

                //remove the last marker
                myMapView.getOverlays().remove(0);

                CenterLocation(loc);
            }

        }
        else if (Action == MotionEvent.ACTION_DOWN){

            MoveMap = false;

        }
        else if (Action == MotionEvent.ACTION_MOVE){                
            MoveMap = true;
        }

        return super.onTouchEvent(arg0, arg1);
        //return false;
    }

I executed the below code and i’m getting this error printed in my

logcat:

11-09 15:00:46.318: W/System.err(664): java.io.IOException: Service not Available
11-09 15:00:46.469: W/System.err(664):  at android.location.Geocoder.getFromLocation(Geocoder.java:117)
11-09 15:00:46.469: W/System.err(664):  at com.project.r
oammeo.MapViewEvents$1.onClick(MapViewEvents.java:79)
11-09 15:00:46.469: W/System.err(664):  at android.view.View.performClick(View.java:2408)
11-09 15:00:46.469: W/System.err(664):  at android.view.View$PerformClick.run(View.java:8816)
11-09 15:00:46.478: W/System.err(664):  at android.os.Handler.handleCallback(Handler.java:587)
11-09 15:00:46.488: W/System.err(664):  at android.os.Handler.dispatchMessage(Handler.java:92)
11-09 15:00:46.498: W/System.err(664):  at android.os.Looper.loop(Looper.java:123)
11-09 15:00:46.524: W/System.err(664):  at android.app.ActivityThread.main(ActivityThread.java:4627)
11-09 15:00:46.589: W/System.err(664):  at java.lang.reflect.Method.invokeNative(Native Method)
11-09 15:00:46.641: W/System.err(664):  at java.lang.reflect.Method.invoke(Method.java:521)
11-09 15:00:46.641: W/System.err(664):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
11-09 15:00:46.660: W/System.err(664):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)

11-09 15:00:46.660: W/System.err(664):  at dalvik.system.NativeStart.main(Native Method)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:42:59+00:00Added an answer on May 26, 2026 at 4:42 pm

    To get the address from the lat, long,

    Try this code,

    Geocoder geocoder = new Geocoder(this, Locale.getDefault());
    List<Address> addresses = geocoder.getFromLocation(lat, lng, 1);
    

    EDIT:

       String addressString;
    
    try {
      Geocoder geocoder = new Geocoder(this, Locale.getDefault());
      List<Address> addresses = geocoder.getFromLocation(lat, lng, 1);
      StringBuilder sb = new StringBuilder();
      if (addresses.size() > 0) {
        Address address = addresses.get(0);
    
        sb.append(address.getLocality()).append("\n");
        sb.append(address.getCountryName());
      }
    
      addressString = sb.toString();
    
      Log.e("Address from lat,long ;", addressString);
     } catch (IOException e) {}
    }
    

    For exception :

    java.io.IOException: Service not Available
    at android.location.Geocoder.getFromLocation(Geocoder.java:117)
    

    It’s a bug in the emulator for 2.2
    http://code.google.com/p/android/issues/detail?id=8816

    also here: http://groups.google.com/group/android-developers/browse_thread/thread/b02c29d746471358

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am now building an application which should store and handle large amounts of
I'm building a Rails application which uses Authlogic for authentication, which I've now set-up
I'm building an application which I'm also testing in Heroku. I ran into some
I am building an application which stores GPS locations in a SQLite database and
Im building a web application which is a process management app. Several different employee
We're building a Silverlight application which will be offered as SaaS. The end product
I'm building a C# application which uses plug-ins. The application must guarantee to the
I'm building a java application which works in a LAN environment, every computer on
I'm looking at building a Rails application which will have some pretty large tables
I'm looking for some opinions here, I'm building a web application which has the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.