[android] option to consume map clicks, consuming location clicks
This commit is contained in:
@@ -43,9 +43,15 @@ public class PressForMarkerActivity extends AppCompatActivity {
|
||||
mapboxMap = map;
|
||||
resetMap();
|
||||
|
||||
mapboxMap.addOnMapLongClickListener(point -> addMarker(point));
|
||||
mapboxMap.addOnMapLongClickListener(point -> {
|
||||
addMarker(point);
|
||||
return false;
|
||||
});
|
||||
|
||||
mapboxMap.addOnMapClickListener(point -> addMarker(point));
|
||||
mapboxMap.addOnMapClickListener(point -> {
|
||||
addMarker(point);
|
||||
return false;
|
||||
});
|
||||
|
||||
if (savedInstanceState != null) {
|
||||
markerList = savedInstanceState.getParcelableArrayList(STATE_MARKER_LIST);
|
||||
|
||||
@@ -64,8 +64,9 @@ public class CameraPositionActivity extends FragmentActivity implements OnMapRea
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapLongClick(@NonNull LatLng point) {
|
||||
public boolean onMapLongClick(@NonNull LatLng point) {
|
||||
toggleLogCameraChanges();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -35,7 +35,10 @@ public class MaxMinZoomActivity extends AppCompatActivity implements OnMapReadyC
|
||||
mapboxMap = map;
|
||||
mapboxMap.setMinZoomPreference(3);
|
||||
mapboxMap.setMaxZoomPreference(5);
|
||||
mapboxMap.setOnMapClickListener(point -> map.setStyle(Style.OUTDOORS, style -> Timber.d("Style Loaded %s", style)));
|
||||
mapboxMap.setOnMapClickListener(point -> {
|
||||
map.setStyle(Style.OUTDOORS, style -> Timber.d("Style Loaded %s", style));
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -71,6 +71,8 @@ public class QueryRenderedFeaturesPropertiesActivity extends AppCompatActivity {
|
||||
// Add a marker on the clicked point
|
||||
marker = mapboxMap.addMarker(new CustomMarkerOptions().position(point).features(features));
|
||||
mapboxMap.selectMarker(marker);
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -63,6 +63,8 @@ public class QuerySourceFeaturesActivity extends AppCompatActivity {
|
||||
List<Feature> features = source.querySourceFeatures(eq(get("key1"), literal("value1")));
|
||||
Toast.makeText(QuerySourceFeaturesActivity.this, String.format("Found %s features",
|
||||
features.size()), Toast.LENGTH_SHORT).show();
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
|
||||
|
||||
@@ -71,6 +71,8 @@ public class DynamicInfoWindowAdapterActivity extends AppCompatActivity implemen
|
||||
infoWindow.update();
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// Focus on Paris
|
||||
|
||||
@@ -109,7 +109,7 @@ public class InfoWindowActivity extends AppCompatActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapLongClick(@NonNull LatLng point) {
|
||||
public boolean onMapLongClick(@NonNull LatLng point) {
|
||||
if (customMarker != null) {
|
||||
// Remove previous added marker
|
||||
mapboxMap.removeAnnotation(customMarker);
|
||||
@@ -122,6 +122,8 @@ public class InfoWindowActivity extends AppCompatActivity
|
||||
.snippet(new DecimalFormat("#.#####").format(point.getLatitude()) + ", "
|
||||
+ new DecimalFormat("#.#####").format(point.getLongitude()))
|
||||
.position(point));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,16 +5,15 @@ import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.design.widget.FloatingActionButton;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapbox.android.core.permissions.PermissionsListener;
|
||||
import com.mapbox.android.core.permissions.PermissionsManager;
|
||||
import com.mapbox.mapboxsdk.location.LocationComponent;
|
||||
import com.mapbox.mapboxsdk.location.modes.RenderMode;
|
||||
import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;
|
||||
import com.mapbox.mapboxsdk.location.LocationComponent;
|
||||
import com.mapbox.mapboxsdk.location.modes.RenderMode;
|
||||
import com.mapbox.mapboxsdk.testapp.R;
|
||||
|
||||
import java.util.List;
|
||||
@@ -33,12 +32,9 @@ public class LocationMapChangeActivity extends AppCompatActivity implements OnMa
|
||||
mapView = findViewById(R.id.mapView);
|
||||
FloatingActionButton stylesFab = findViewById(R.id.fabStyles);
|
||||
|
||||
stylesFab.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap.setStyleUrl(Utils.getNextStyle());
|
||||
}
|
||||
stylesFab.setOnClickListener(v -> {
|
||||
if (mapboxMap != null) {
|
||||
mapboxMap.setStyleUrl(Utils.getNextStyle());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -86,6 +82,12 @@ public class LocationMapChangeActivity extends AppCompatActivity implements OnMa
|
||||
locationComponent.activateLocationComponent(this);
|
||||
locationComponent.setLocationComponentEnabled(true);
|
||||
locationComponent.setRenderMode(RenderMode.COMPASS);
|
||||
|
||||
locationComponent.addOnLocationClickListener(
|
||||
() -> Toast.makeText(this, "Location clicked", Toast.LENGTH_SHORT).show());
|
||||
|
||||
locationComponent.addOnLocationLongClickListener(
|
||||
() -> Toast.makeText(this, "Location long clicked", Toast.LENGTH_SHORT).show());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -101,6 +101,8 @@ public class DoubleMapActivity extends AppCompatActivity {
|
||||
// test if we can open 2 activities after each other
|
||||
Toast.makeText(mapViewMini.getContext(), "Creating a new Activity instance",Toast.LENGTH_SHORT).show();
|
||||
startActivity(new Intent(mapViewMini.getContext(), DoubleMapActivity.class));
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -95,6 +95,8 @@ class DraggableMarkerActivity : AppCompatActivity() {
|
||||
Snackbar.LENGTH_LONG)
|
||||
.show()
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
draggableSymbolsManager = DraggableSymbolsManager(
|
||||
@@ -185,6 +187,7 @@ class DraggableMarkerActivity : AppCompatActivity() {
|
||||
onSymbolDragStarted(id)
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
androidGesturesManager.setMoveGestureListener(MyMoveGestureListener())
|
||||
|
||||
@@ -105,6 +105,8 @@ public class SymbolGeneratorActivity extends AppCompatActivity implements OnMapR
|
||||
"hello from: " + feature.getStringProperty(FEATURE_NAME),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClick(@NonNull LatLng point) {
|
||||
public boolean onMapClick(@NonNull LatLng point) {
|
||||
// Query which features are clicked
|
||||
PointF screenLoc = mapboxMap.getProjection().toScreenLocation(point);
|
||||
List<Feature> features = mapboxMap.queryRenderedFeatures(screenLoc, MARKER_LAYER);
|
||||
@@ -162,6 +162,8 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap.
|
||||
}
|
||||
geoJsonSource.setGeoJson(markerCollection);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void toggleTextSize() {
|
||||
|
||||
@@ -125,6 +125,8 @@ public class ZoomFunctionSymbolLayerActivity extends AppCompatActivity {
|
||||
} else {
|
||||
Timber.e("No features found");
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user