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 4260288
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:54:00+00:00 2026-05-21T05:54:00+00:00

My code currently displays the users location on a map… using the code below

  • 0

My code currently displays the users location on a map… using the code below

private void initMyLocation() {
    final MyLocationOverlay overlay = new MyLocationOverlay(this, map);
    overlay.enableMyLocation();

    overlay.runOnFirstFix(new Runnable() {
        public void run() {
            controller.setZoom(8);
            controller.animateTo(overlay.getMyLocation());
        }
    });
    map.getOverlays().add(overlay);
}

I want to use the current location of the user and perform geocding on it to display the address as a toast message.. Would i have to delete the code above and retrieve the location by separate longitude and latitude values? Preferably i wouldnt want to go changing the code above as it already works.. I can’t seem to find any good tutorials out there.. Could someone please direct me to one?
Thanks

  • 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-21T05:54:01+00:00Added an answer on May 21, 2026 at 5:54 am
    1. Since MyLocationOverlay already implements LocationListener, you could simply subclass it and override the onLocationChanged listener method and perform your geocoding there (preferably in a new thread/async task to avoid blocking the overlay processing!).

      Something like:

      private void initMyLocation() {
          final MyLocationOverlay overlay = new MyLocationOverlay(this, map){
              public void onLocationChanged(android.location.Location location)
              {
                  //subclass AsyncTask to take a location parameter for 
                  //doInBackground where it geocodes and then passes a String
                  //to onPostExecute where you can display a toast
                  new MyAsyncTask().execute(location);
      
                  //remember to call the parent implementation to avoid breaking
                  //MyLocationOverlay default functionality
                  super.onLocationChanged(location);
              }
          };
          overlay.enableMyLocation();
      
          overlay.runOnFirstFix(new Runnable() {
              public void run() {
                  controller.setZoom(8);
                  controller.animateTo(overlay.getMyLocation());
              }
          });
          map.getOverlays().add(overlay);
      }
      
    2. The other option might be to write a custom LocationListener and register for updates for location and do pretty much the same thing as in the code above. IMO, this is probably redundant and unnecessarily expensive since, as explained above, you already have a LocationListener implementation to hook into so why write another?

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

Sidebar

Related Questions

Why does this code fail to display the category name Apples using the current
The code currently does this and the fgetpos does handle files larger than 4GB
Here is the code currently used. public String getStringFromDoc(org.w3c.dom.Document doc) { try { DOMSource
We currently have code like this: Dim xDoc = XDocument.Load(myXMLFilePath) The only way we
I currently have code in my ApplicationController to check if a user is logged
I am currently publishing code behind .aspx in SharePoint. I can automatically publish the
I'm currently refactoring code to replace Convert.To's to TryParse. I've come across the following
Possible Duplicate: How do I get the HMODULE for the currently executing code? I'm
There is probably is simple fix for this but I currently have code similar
I currently have some code that will produce a crash dump when my application

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.