use of com.mapbox.mapboxsdk.annotations.PolygonOptions in project apps-android-commons by commons-app.
the class NearbyMapFragment method addCurrentLocationMarker.
/**
* Adds a marker for the user's current position. Adds a
* circle which uses the accuracy * 2, to draw a circle
* which represents the user's position with an accuracy
* of 95%.
*/
public void addCurrentLocationMarker(MapboxMap mapboxMap) {
MarkerOptions currentLocationMarker = new MarkerOptions().position(new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude()));
mapboxMap.addMarker(currentLocationMarker);
List<LatLng> circle = createCircleArray(curLatLng.getLatitude(), curLatLng.getLongitude(), curLatLng.getAccuracy() * 2, 100);
mapboxMap.addPolygon(new PolygonOptions().addAll(circle).strokeColor(Color.parseColor("#55000000")).fillColor(Color.parseColor("#11000000")));
}
use of com.mapbox.mapboxsdk.annotations.PolygonOptions in project mapbox-plugins-android by mapbox.
the class GeoJsonPlugin method drawOnMap.
/**
* Drawing {@link DataModel} element on to the map
*
* @param dataModel list of polylines, polygons, and points
*/
private void drawOnMap(DataModel dataModel) {
if (dataModel != null) {
List<MarkerData> markers = dataModel.getMarkers();
if (markers != null) {
if (!markers.isEmpty()) {
for (MarkerData markerData : dataModel.getMarkers()) {
Marker marker = map.addMarker(new MarkerOptions().position(markerData.getPoint()));
markerCollectionHashMap.put(marker, markerData);
}
}
}
List<PolyData> polygons = dataModel.getPolygons();
if (polygons != null) {
if (!polygons.isEmpty()) {
for (PolyData polyData : polygons) {
if (isRandomFillColor) {
fillColor = getRandomMaterialColor("400");
}
if (isRandomStockColor) {
stockColor = getRandomMaterialColor("400");
}
map.addPolygon(new PolygonOptions().addAll(polyData.getPoints()).fillColor(fillColor).strokeColor(stockColor));
}
}
}
List<PolyData> polylines = dataModel.getPolylines();
if (polylines != null) {
if (!polylines.isEmpty()) {
for (PolyData polyData : polylines) {
if (isRandomStockColor) {
stockColor = getRandomMaterialColor("400");
}
map.addPolyline(new PolylineOptions().addAll(polyData.getPoints()).color(stockColor).width(width));
}
}
}
if (dataModel.getBounds() != null) {
map.easeCamera(CameraUpdateFactory.newLatLngBounds(dataModel.getBounds(), 50), 500);
}
// set onMarkerClick Listener and pass properties of marker to the MarkerEventListener
map.setOnMarkerClickListener(new MapboxMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(@NonNull Marker marker) {
MarkerData markerData = markerCollectionHashMap.get(marker);
if (markerEventListener != null) {
markerEventListener.onMarkerClickListener(marker, markerData.getProperties());
}
return false;
}
});
}
}
Aggregations