use of com.mapbox.mapboxsdk.annotations.MarkerOptions 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.MarkerOptions 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;
}
});
}
}
use of com.mapbox.mapboxsdk.annotations.MarkerOptions in project mapbox-navigation-android by mapbox.
the class RerouteActivity method userOffRoute.
@Override
public void userOffRoute(Location location) {
Point newOrigin = Point.fromLngLat(location.getLongitude(), location.getLatitude());
getRoute(newOrigin, destination, location.getBearing());
Snackbar.make(contentLayout, "User Off Route", Snackbar.LENGTH_SHORT).show();
mapboxMap.addMarker(new MarkerOptions().position(new LatLng(location.getLatitude(), location.getLongitude())));
}
use of com.mapbox.mapboxsdk.annotations.MarkerOptions in project mapbox-navigation-android by mapbox.
the class RerouteActivity method onMapClick.
@Override
public void onMapClick(@NonNull LatLng point) {
if (!running || mapboxMap == null) {
return;
}
mapboxMap.addMarker(new MarkerOptions().position(point));
mapboxMap.setOnMapClickListener(null);
Point newDestination = Point.fromLngLat(point.getLongitude(), point.getLatitude());
mockLocationEngine.moveToLocation(newDestination);
destination = Point.fromLngLat(point.getLongitude(), point.getLatitude());
tracking = false;
}
use of com.mapbox.mapboxsdk.annotations.MarkerOptions in project mapbox-navigation-android by mapbox.
the class NavigationView method addMarker.
/**
* Creates a marker based on the
* {@link Point} destination coordinate.
*
* @param position where the marker should be placed
*/
@Override
public void addMarker(Point position) {
LatLng markerPosition = new LatLng(position.latitude(), position.longitude());
markers.add(map.addMarker(new MarkerOptions().position(markerPosition).icon(ThemeSwitcher.retrieveMapMarker(getContext()))));
}
Aggregations