Refactored PointAnnotation to be called Markers a la Google Maps
This commit is contained in:
@@ -26,7 +26,6 @@ import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.widget.ZoomButtonsController;
|
||||
import android.util.Log;
|
||||
|
||||
import com.almeros.android.multitouch.gesturedetectors.RotateGestureDetector;
|
||||
import com.almeros.android.multitouch.gesturedetectors.TwoFingerGestureDetector;
|
||||
@@ -205,8 +204,8 @@ public class MapView extends SurfaceView {
|
||||
}
|
||||
}
|
||||
|
||||
public void addAnnotation(LatLng marker) {
|
||||
mNativeMapView.addAnnotation(marker);
|
||||
public void addMarker(LatLng marker) {
|
||||
mNativeMapView.addMarker(marker);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.mapbox.mapboxgl.views;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.view.Surface;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mapbox.mapboxgl.geometry.LatLng;
|
||||
import com.mapbox.mapboxgl.geometry.LatLngZoom;
|
||||
@@ -214,8 +213,8 @@ class NativeMapView {
|
||||
nativeSetLatLng(mNativeMapViewPtr, latLng, duration);
|
||||
}
|
||||
|
||||
public void addAnnotation(LatLng latLng) {
|
||||
nativeAddAnnotation(mNativeMapViewPtr, latLng);
|
||||
public void addMarker(LatLng latLng) {
|
||||
nativeAddMarker(mNativeMapViewPtr, latLng);
|
||||
}
|
||||
|
||||
public LatLng getLatLng() {
|
||||
@@ -450,7 +449,7 @@ class NativeMapView {
|
||||
private native void nativeSetLatLng(long nativeMapViewPtr, LatLng latLng,
|
||||
long duration);
|
||||
|
||||
private native void nativeAddAnnotation(long nativeMapViewPtr, LatLng latLng);
|
||||
private native void nativeAddMarker(long nativeMapViewPtr, LatLng latLng);
|
||||
|
||||
private native LatLng nativeGetLatLng(long nativeMapViewPtr);
|
||||
|
||||
|
||||
@@ -77,8 +77,8 @@ public class MainActivity extends ActionBarActivity {
|
||||
private float mCompassBearing;
|
||||
private boolean mCompassValid = false;
|
||||
|
||||
// Used for point annotations
|
||||
private boolean mIsPointAnnotationsOn = false;
|
||||
// Used for markers
|
||||
private boolean mIsMarkersOn = false;
|
||||
|
||||
//
|
||||
// Lifecycle events
|
||||
@@ -213,9 +213,9 @@ public class MainActivity extends ActionBarActivity {
|
||||
}
|
||||
return true;
|
||||
|
||||
case R.id.action_point_annotations:
|
||||
// Toggle point annotations
|
||||
togglePointAnnotations(!mIsPointAnnotationsOn);
|
||||
case R.id.action_markers:
|
||||
// Toggle markers
|
||||
toggleMarkers(!mIsMarkersOn);
|
||||
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
@@ -257,29 +257,29 @@ public class MainActivity extends ActionBarActivity {
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable / Disable Point annotations.
|
||||
* Enable / Disable markers.
|
||||
*
|
||||
* TODO: Implement updating the UI and removing point annotations from the map.
|
||||
* TODO: Implement updating the UI and removing markers from the map.
|
||||
*
|
||||
* @param enablePointAnnotations
|
||||
* @param enableMarkers
|
||||
*/
|
||||
private void togglePointAnnotations(boolean enablePointAnnotations) {
|
||||
if (enablePointAnnotations) {
|
||||
if (!mIsPointAnnotationsOn) {
|
||||
mIsPointAnnotationsOn = true;
|
||||
addPointAnnotations();
|
||||
private void toggleMarkers(boolean enableMarkers) {
|
||||
if (enableMarkers) {
|
||||
if (!mIsMarkersOn) {
|
||||
mIsMarkersOn = true;
|
||||
addMarkers();
|
||||
}
|
||||
} else {
|
||||
if (mIsPointAnnotationsOn) {
|
||||
mIsPointAnnotationsOn = false;
|
||||
if (mIsMarkersOn) {
|
||||
mIsMarkersOn = false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addPointAnnotations() {
|
||||
private void addMarkers() {
|
||||
LatLng backLot = new LatLng(38.649441, -121.369064);
|
||||
mMapFragment.getMap().addAnnotation(backLot);
|
||||
mMapFragment.getMap().addMarker(backLot);
|
||||
}
|
||||
|
||||
// This class forwards location updates to updateLocation()
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
android:icon="@drawable/ic_action_about"
|
||||
android:title="@string/action_debug"
|
||||
app:showAsAction="ifRoom" />
|
||||
<item android:id="@+id/action_point_annotations"
|
||||
<item android:id="@+id/action_markers"
|
||||
android:icon="@android:drawable/ic_menu_myplaces"
|
||||
android:title="@string/action_point_annotations"
|
||||
app:showAsAction="ifRoom" />
|
||||
|
||||
Reference in New Issue
Block a user