use of com.mapbox.mapboxsdk.plugins.annotation.FillOptions in project mapbox-plugins-android by mapbox.
the class FillChangeActivity method onMapReady.
@Override
public void onMapReady(@NonNull MapboxMap map) {
map.setStyle(new Style.Builder().fromUri(Style.MAPBOX_STREETS), style -> {
fillManager = new FillManager(mapView, map, style, "aerialway");
fillManager.addClickListener(fill -> {
Toast.makeText(FillChangeActivity.this, "Clicked: " + fill.getId(), Toast.LENGTH_SHORT).show();
return false;
});
fill = fillManager.create(new FillOptions().withLatLngs(STAR_SHAPE_POINTS).withFillColor(ColorUtils.colorToRgbaString(BLUE_COLOR)));
});
}
use of com.mapbox.mapboxsdk.plugins.annotation.FillOptions in project mapbox-plugins-android by mapbox.
the class FillActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_annotation);
mapView = findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(mapboxMap -> mapboxMap.setStyle(Style.MAPBOX_STREETS, style -> {
findViewById(R.id.fabStyles).setOnClickListener(v -> mapboxMap.setStyle(Utils.INSTANCE.getNextStyle()));
mapboxMap.moveCamera(CameraUpdateFactory.zoomTo(2));
fillManager = new FillManager(mapView, mapboxMap, style);
fillManager.addClickListener(fill -> {
Toast.makeText(FillActivity.this, String.format("Fill clicked %s with title: %s", fill.getId(), getTitleFromFill(fill)), Toast.LENGTH_SHORT).show();
return false;
});
fillManager.addLongClickListener(fill -> {
Toast.makeText(FillActivity.this, String.format("Fill long clicked %s with title: %s", fill.getId(), getTitleFromFill(fill)), Toast.LENGTH_SHORT).show();
return false;
});
// create a fixed fill
List<LatLng> innerLatLngs = new ArrayList<>();
innerLatLngs.add(new LatLng(-35.317366, -74.179687));
innerLatLngs.add(new LatLng(-35.317366, -30.761718));
innerLatLngs.add(new LatLng(4.740675, -30.761718));
innerLatLngs.add(new LatLng(4.740675, -74.179687));
innerLatLngs.add(new LatLng(-35.317366, -74.179687));
List<List<LatLng>> latLngs = new ArrayList<>();
latLngs.add(innerLatLngs);
FillOptions fillOptions = new FillOptions().withLatLngs(latLngs).withData(new JsonPrimitive("Foobar")).withFillColor(ColorUtils.colorToRgbaString(Color.RED));
fillManager.create(fillOptions);
// random add fills across the globe
List<FillOptions> fillOptionsList = new ArrayList<>();
for (int i = 0; i < 3; i++) {
int color = Color.argb(255, random.nextInt(256), random.nextInt(256), random.nextInt(256));
fillOptionsList.add(new FillOptions().withLatLngs(createRandomLatLngs()).withFillColor(ColorUtils.colorToRgbaString(color)));
}
fillManager.create(fillOptionsList);
try {
fillManager.create(FeatureCollection.fromJson(Utils.INSTANCE.loadStringFromAssets(this, "annotations.json")));
} catch (IOException e) {
throw new RuntimeException("Unable to parse annotations.json");
}
}));
}
Aggregations