Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid: Best way to do reverse geocoding in MyLocationOverlay?
    primarykey
    data
    text
    <p>I'm using a MyLocationOverlay to update the map with the users location as they're driving. I'm trying to implement a text view that shows their current location in terms of the street name, city and state. This all works fine but it seems like the update frequency of MyLocationOverlay is causing the map to lag and freeze for a second or two. I'm not sure if the text .setText method is causing it to freeze or if the number of times the method gets called. What is the proper way to implement updating the user with the name city and state? I'm using a new thread is this the right way? Here's my code in the onLocationChanged method of MyLocationOverlay:</p> <pre><code>@Override public synchronized void onLocationChanged(Location location) { super.onLocationChanged(location); mLocation = location; // only move to new position if enabled and we are in an border-area if (this.isMyLocationEnabled() &amp;&amp; animateToCurrentLocation) { mMapController.animateTo(getMyLocation()); } this.runOnFirstFix(new Runnable() { public void run() { Log.d(TAG, "Running"); if (mLocation != null) { Geocoder gc = new Geocoder(mContext, Locale.getDefault()); try { List&lt;Address&gt; addresses = gc.getFromLocation(mLocation.getLatitude(), mLocation.getLongitude(), 1); if (addresses != null &amp;&amp; addresses.size() &gt; 0) { txtStreetAddress.setText(addresses.get(0).getThoroughfare() + " " + addresses.get(0).getLocality() + ", " + addresses.get(0).getAdminArea()); } } catch (IOException e) { } } } }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload