use of com.mapbox.mapboxsdk.annotations.PolylineOptions 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.PolylineOptions in project osm-contributor by jawg.
the class MapFragment method onCameraChangeUpdatePolyline.
public void onCameraChangeUpdatePolyline() {
if (editionPolyline != null) {
List<LatLng> points = editionPolyline.getPoints();
points.set(1, mapboxMap.getCameraPosition().target);
removePolyline(editionPolyline);
editionPolyline = new PolylineOptions().addAll(points).alpha(0.4f).width(1.8f).color(Color.parseColor("#F57C00"));
mapboxMap.addPolyline(editionPolyline);
}
}
use of com.mapbox.mapboxsdk.annotations.PolylineOptions in project androidApp by InspectorIncognito.
the class PolylineEngine method addBusRoutePolyline.
@NonNull
public Polyline addBusRoutePolyline(MapboxMap mapboxMap, ArrayList<LatLng> points, int colorId) {
if (busRouteEndFeature == null) {
setupPolylineVars(mapboxMap);
}
Feature startPoint = Feature.fromGeometry(Point.fromCoordinates(Position.fromCoordinates(points.get(0).getLongitude(), points.get(0).getLatitude())));
Feature endPoint = Feature.fromGeometry(Point.fromCoordinates(Position.fromCoordinates(points.get(points.size() - 1).getLongitude(), points.get(points.size() - 1).getLatitude())));
busRouteStartFeature = FeatureCollection.fromFeatures(new Feature[] { startPoint });
busRouteEndFeature = FeatureCollection.fromFeatures(new Feature[] { endPoint });
refreshSourceWithFeatures(busRouteStartSource, busRouteStartFeature);
refreshSourceWithFeatures(busRouteEndSource, busRouteEndFeature);
return mapboxMap.addPolyline(new PolylineOptions().addAll(points).color(ContextCompat.getColor(TranSappApplication.getAppContext(), colorId)).width(4));
}
use of com.mapbox.mapboxsdk.annotations.PolylineOptions in project osm-contributor by jawg.
the class MapFragment method clearAllNodeRef.
private void clearAllNodeRef() {
for (WayMarkerOptions locationMarker : markersNodeRef.values()) {
removeWayMarker(locationMarker);
}
for (PolylineOptions polylineOptions : polylinesWays.values()) {
removePolyline(polylineOptions);
}
markersNodeRef.clear();
polylinesWays.clear();
}
use of com.mapbox.mapboxsdk.annotations.PolylineOptions in project osm-contributor by jawg.
the class MapFragment method buildEditionPolygon.
private void buildEditionPolygon() {
// Current selected poiNodeRef
PoiNodeRef currentPoiNodeRef = wayMarkerSelected.getPoiNodeRef();
// Polyline related to this poiNodeRef
PolylineOptions currentPolyline = polylinesWays.get(currentPoiNodeRef.getId());
// Item of the poiNodeRef in the polilyne
int indexOfPoiNodeRef = currentPolyline.getPoints().indexOf(new LatLng(currentPoiNodeRef.getLatitude(), currentPoiNodeRef.getLongitude()));
LatLng previousPoint = currentPolyline.getPoints().get(indexOfPoiNodeRef == 0 ? indexOfPoiNodeRef + 1 : indexOfPoiNodeRef - 1);
LatLng nextPoint = currentPolyline.getPoints().get(indexOfPoiNodeRef == currentPolyline.getPoints().size() - 1 ? indexOfPoiNodeRef - 1 : indexOfPoiNodeRef + 1);
editionPolyline = new PolylineOptions().add(previousPoint, currentPolyline.getPoints().get(indexOfPoiNodeRef), nextPoint).alpha(0.4f).width(1.8f).color(Color.parseColor("#F57C00"));
mapboxMap.addPolyline(editionPolyline);
}
Aggregations