Skip to content

Commit

Permalink
MapView.getSpatialReference called on UI thread
Browse files Browse the repository at this point in the history
  • Loading branch information
mani8177 committed Jul 6, 2015
1 parent 5e92e31 commit 70159e0
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import com.esri.core.geometry.SpatialReference;
import com.esri.core.map.CallbackListener;
import com.esri.core.tasks.geocode.Locator;
import com.esri.core.tasks.geocode.LocatorFindParameters;
import com.esri.core.tasks.geocode.LocatorGeocodeResult;
import com.esri.core.tasks.geocode.LocatorSuggestionParameters;
import com.esri.core.tasks.geocode.LocatorSuggestionResult;
Expand Down Expand Up @@ -74,7 +73,7 @@ public class MainActivity extends Activity {
private static ProgressDialog mProgressDialog;
private LocatorSuggestionParameters suggestParams;

private final Map<String,Point> suggestMap = new TreeMap<String,Point>();
private final Map<String,Point> suggestMap = new TreeMap<>();

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand Down Expand Up @@ -248,8 +247,17 @@ protected Point doInBackground(String... params) {
try {
temp = suggestMap.get(params[0]);
// Project the Location to WGS 84
resultPoint = (Point) GeometryEngine.project(temp, mMapView.getSpatialReference(), SpatialReference.create(4326));
} catch (Exception e) {}
runOnUiThread(new Runnable() {
@Override
public void run() {
resultPoint = (Point) GeometryEngine.project(temp, mMapView.getSpatialReference(), SpatialReference.create(4326));
}
});

} catch (Exception e) {
Log.e(TAG,"Error in fetching the Location");
e.printStackTrace();
}
} while(temp == null);

return resultPoint;
Expand Down

0 comments on commit 70159e0

Please sign in to comment.