New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add map type selector #3

Open
wants to merge 3 commits into
base: master
from
File filter...
Filter file types
Jump to file or symbol
Failed to load files and symbols.
+60 −1
Diff settings

Always

Just for now

@@ -34,9 +34,12 @@
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

@@ -161,6 +164,8 @@
private ArrayList<FavoriteItem> favList;
private CompositePermissionListener locationPermissionListener;
private MultiplePermissionsListener cameraPermissionListener;
protected List mapTypeValuesList;
private Spinner mapTypeSpinner;

private Location userLocation;
LocationListener locationListener = new LocationListener() {
@@ -310,9 +315,42 @@ private void setUpClusterer() {
map.setOnMarkerClickListener(clusterManager);
}

private void setUpMapTypeMenu(final GoogleMap googleMap) {
mapTypeSpinner = (Spinner) getActivity().findViewById(R.id.mapTypeSpinner);
String[] mapTypeValues = getContext().getResources().getStringArray(R.array.map_type_values);
mapTypeValuesList = Arrays.asList(mapTypeValues);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(
getContext(),
android.R.layout.simple_spinner_dropdown_item,
mapTypeValuesList);
mapTypeSpinner.setAdapter(arrayAdapter);

mapTypeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
switch (position) {
case 0:
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
break;
case 1:
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
break;
case 2:
googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
break;
}
}

@Override
public void onNothingSelected(AdapterView<?> parent) {}
});
}

@Override
public void onMapReady(GoogleMap googleMap) {
this.map = googleMap;
setUpMapTypeMenu(this.map);
map.setInfoWindowAdapter(new BubbleAdapter(getActivity()));
map.setOnInfoWindowClickListener(this);
map.getUiSettings().setMapToolbarEnabled(false);
@@ -125,4 +125,15 @@
android:layout_height="wrap_content"
android:visibility="gone"/>

</RelativeLayout>
<Spinner
android:id="@+id/mapTypeSpinner"
android:layout_width="wrap_content"
android:layout_height="38dp"
android:background="@drawable/button_map"
android:spinnerMode="dropdown"
android:layout_alignTop="@+id/reloadButton"
android:layout_toRightOf="@+id/reloadButton"
android:layout_toEndOf="@+id/reloadButton"
android:elevation="6dp"/>

</RelativeLayout>
@@ -21,4 +21,9 @@
<item>Bicis</item>
<item>No Activas</item>
</string-array>
<string-array name="map_type_values">
<item>Normal</item>
<item>Híbrido</item>
<item>Terreno</item>
</string-array>
</resources>
@@ -21,4 +21,9 @@
<item>Bikes</item>
<item>Not Active</item>
</string-array>
<string-array name="map_type_values">
<item>Normal</item>
<item>Hybrid</item>
<item>Terrain</item>
</string-array>
</resources>
ProTip! Use n and p to navigate between commits in a pull request.