Search in sources :

Example 41 with LatLngBounds

use of com.google.android.gms.maps.model.LatLngBounds in project iNaturalistAndroid by inaturalist.

the class ExploreActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setElevation(0);
    actionBar.setCustomView(R.layout.explore_action_bar_new);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.getCustomView().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(ExploreActivity.this, ExploreSearchActivity.class);
            intent.putExtra(ExploreSearchActivity.SEARCH_FILTERS, mSearchFilters);
            startActivityForResult(intent, SEARCH_REQUEST_CODE);
        }
    });
    mHelper = new ActivityHelper(this);
    setContentView(R.layout.explore);
    if (savedInstanceState == null) {
        mActiveViewType = VIEW_TYPE_OBSERVATIONS;
        mTotalResults = new int[] { NOT_LOADED, NOT_LOADED, NOT_LOADED, NOT_LOADED };
        mResults = (List<JSONObject>[]) new List[] { null, null, null, null };
        mSearchFilters = new ExploreSearchFilters();
        mLastMapBounds = null;
    } else {
        mActiveViewType = savedInstanceState.getInt("mActiveViewType");
        mTotalResults = savedInstanceState.getIntArray("mTotalResults");
        mObservationsViewMode = savedInstanceState.getInt("mObservationsViewMode");
        mSearchFilters = (ExploreSearchFilters) savedInstanceState.getSerializable("mSearchFilters");
        mCurrentResultsPage = savedInstanceState.getIntArray("mCurrentResultsPage");
        mLoadingNextResults = savedInstanceState.getBooleanArray("mLoadingNextResults");
        mObservationsMapType = savedInstanceState.getInt("mObservationsMapType", GoogleMap.MAP_TYPE_TERRAIN);
        mMapMoved = savedInstanceState.getBoolean("mMapMoved");
        mResults = (List<JSONObject>[]) new List[] { null, null, null, null };
        mResults[VIEW_TYPE_OBSERVATIONS] = mHelper.loadListFromBundle(savedInstanceState, "mObservations");
        mResults[VIEW_TYPE_SPECIES] = mHelper.loadListFromBundle(savedInstanceState, "mSpecies");
        mResults[VIEW_TYPE_OBSERVERS] = mHelper.loadListFromBundle(savedInstanceState, "mObservers");
        mResults[VIEW_TYPE_IDENTIFIERS] = mHelper.loadListFromBundle(savedInstanceState, "mIdentifiers");
        for (int i = 0; i < mResults.length; i++) {
            mListViewIndex.put("mList" + i, savedInstanceState.getInt("mList" + i + "Index"));
            mListViewOffset.put("mList" + i, savedInstanceState.getInt("mList" + i + "Offset"));
        }
        VisibleRegion vr = savedInstanceState.getParcelable("mapRegion");
        mLastMapBounds = new LatLngBounds(new LatLng(vr.nearLeft.latitude, vr.farLeft.longitude), new LatLng(vr.farRight.latitude, vr.farRight.longitude));
    }
    onDrawerCreate(savedInstanceState);
    // Tab Initialization
    initializeTabs();
}
Also used : LatLngBounds(com.google.android.gms.maps.model.LatLngBounds) Intent(android.content.Intent) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) Point(android.graphics.Point) VisibleRegion(com.google.android.gms.maps.model.VisibleRegion) List(java.util.List) ArrayList(java.util.ArrayList) LatLng(com.google.android.gms.maps.model.LatLng) ActionBar(android.support.v7.app.ActionBar)

Example 42 with LatLngBounds

use of com.google.android.gms.maps.model.LatLngBounds in project iNaturalistAndroid by inaturalist.

the class ActivityHelper method addCircle.

private CameraUpdate addCircle(GoogleMap map, LatLng latlng, int radius, Observation observation, boolean updateCamera) {
    int obsColor = observationColor(observation);
    CircleOptions opts = new CircleOptions().center(latlng).radius(radius).fillColor(// Add 50% opacity
    0x80FFFFFF & obsColor).strokeColor(obsColor);
    map.addCircle(opts);
    if (!updateCamera) {
        return null;
    }
    LatLngBounds bounds = new LatLngBounds.Builder().include(SphericalUtil.computeOffset(latlng, radius, 0)).include(SphericalUtil.computeOffset(latlng, radius, 90)).include(SphericalUtil.computeOffset(latlng, radius, 180)).include(SphericalUtil.computeOffset(latlng, radius, 270)).build();
    return CameraUpdateFactory.newLatLngBounds(bounds, 10);
}
Also used : CircleOptions(com.google.android.gms.maps.model.CircleOptions) LatLngBounds(com.google.android.gms.maps.model.LatLngBounds)

Aggregations

LatLngBounds (com.google.android.gms.maps.model.LatLngBounds)42 LatLng (com.google.android.gms.maps.model.LatLng)27 CameraUpdate (com.google.android.gms.maps.CameraUpdate)11 Marker (com.google.android.gms.maps.model.Marker)6 Intent (android.content.Intent)5 MarkerOptions (com.google.android.gms.maps.model.MarkerOptions)5 ArrayList (java.util.ArrayList)5 View (android.view.View)4 JSONException (org.json.JSONException)4 Handler (android.os.Handler)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 AutocompletePrediction (com.google.android.gms.location.places.AutocompletePrediction)3 AutocompletePredictionBuffer (com.google.android.gms.location.places.AutocompletePredictionBuffer)3 GoogleMap (com.google.android.gms.maps.GoogleMap)3 PolylineOptions (com.google.android.gms.maps.model.PolylineOptions)3 HashMap (java.util.HashMap)3 JSONObject (org.json.JSONObject)3 SuppressLint (android.annotation.SuppressLint)2 Cursor (android.database.Cursor)2