attempting to put one annotation on the map - gets to the native call and then nothing happens

This commit is contained in:
Nicholas Hallahan
2015-06-20 16:21:41 -07:00
parent 1779dd870d
commit ef31fc5aed
6 changed files with 75 additions and 4 deletions

View File

@@ -77,6 +77,9 @@ public class MainActivity extends ActionBarActivity {
private float mCompassBearing;
private boolean mCompassValid = false;
// Used for point annotations
private boolean mIsPointAnnotationsOn = false;
//
// Lifecycle events
//
@@ -210,6 +213,10 @@ public class MainActivity extends ActionBarActivity {
}
return true;
case R.id.action_point_annotations:
// Toggle point annotations
togglePointAnnotations(!mIsPointAnnotationsOn);
default:
return super.onOptionsItemSelected(item);
}
@@ -249,6 +256,32 @@ public class MainActivity extends ActionBarActivity {
}
}
/**
* Enable / Disable Point annotations.
*
* TODO: Implement updating the UI and removing point annotations from the map.
*
* @param enablePointAnnotations
*/
private void togglePointAnnotations(boolean enablePointAnnotations) {
if (enablePointAnnotations) {
if (!mIsPointAnnotationsOn) {
mIsPointAnnotationsOn = true;
addPointAnnotations();
}
} else {
if (mIsPointAnnotationsOn) {
mIsPointAnnotationsOn = false;
}
}
}
private void addPointAnnotations() {
LatLng backLot = new LatLng(38.649441, -121.369064);
mMapFragment.getMap().addAnnotation(backLot);
}
// This class forwards location updates to updateLocation()
private class GpsListener implements LocationListener {

View File

@@ -1,11 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_gps"
android:icon="@drawable/ic_action_location_searching"
android:title="@string/action_gps"
app:showAsAction="ifRoom" />
<item android:id="@+id/action_debug"
android:icon="@drawable/ic_action_about"
android:title="@string/action_debug"
app:showAsAction="ifRoom" />
<item android:id="@+id/action_point_annotations"
android:icon="@android:drawable/ic_menu_myplaces"
android:title="@string/action_point_annotations"
app:showAsAction="ifRoom" />
<item android:id="@+id/action_gps"
android:icon="@drawable/ic_action_location_searching"
android:title="@string/action_gps"
app:showAsAction="ifRoom" />
</menu>

View File

@@ -7,6 +7,8 @@
<string name="action_debug">Toggle debug mode</string>
<string name="action_point_annotations">Toggle point annotations</string>
<string name="label_fps">FPS:</string>
<string name="compass_desc">Map compass. Click to reset the map rotation to North.</string>