use of com.mapbox.services.commons.geojson.Feature in project androidApp by InspectorIncognito.
the class MapBusIconsBuilder method setIconsAndViews.
public void setIconsAndViews(LayoutInflater inflater, HashMap<String, Bitmap> imagesMap, HashMap<String, View> viewMap) {
for (Feature feature : featureCollection.getFeatures()) {
String id = feature.getStringProperty(Marker.PROPERTY_ID);
BusMarker marker = (BusMarker) feature;
ServerSentBus bus = marker.getBus();
setBusIcons(id, bus, inflater, imagesMap, viewMap, false);
}
}
use of com.mapbox.services.commons.geojson.Feature in project androidApp by InspectorIncognito.
the class BusStopClickHandler method handleMarkerClick.
public Feature handleMarkerClick(Feature feature, FeatureCollection busStopFeatures) {
Feature newSelectedFeature = null;
String id = feature.getStringProperty(PROPERTY_ID);
List<Feature> featureList = busStopFeatures.getFeatures();
for (int i = 0; i < featureList.size(); i++) {
if (featureList.get(i).getStringProperty(PROPERTY_ID).equals(id)) {
Feature selectedFeature = featureList.get(i);
if (selectedFeature.getBooleanProperty(PROPERTY_SELECTED)) {
selectedFeature.addBooleanProperty(BusStopMarker.PROPERTY_MAXIMIZED, !selectedFeature.getBooleanProperty(PROPERTY_MAXIMIZED));
} else {
selectedFeature.getProperties().addProperty(PROPERTY_SELECTED, true);
selectedFeature.getProperties().addProperty(PROPERTY_MAXIMIZED, true);
selectedFeature.getProperties().addProperty(PROPERTY_LOADING, true);
newSelectedFeature = selectedFeature;
}
} else {
Feature nonSelectedFeature = featureList.get(i);
nonSelectedFeature.getProperties().addProperty(PROPERTY_SELECTED, false);
}
}
return newSelectedFeature;
}
use of com.mapbox.services.commons.geojson.Feature in project mapbox-navigation-android by mapbox.
the class NavigationMapRoute method buildTrafficFeaturesFromRoute.
private void buildTrafficFeaturesFromRoute(DirectionsRoute route, int index, List<Feature> features, LineString lineString) {
for (RouteLeg leg : route.legs()) {
if (leg.annotation() != null && leg.annotation().congestion() != null) {
for (int i = 0; i < leg.annotation().congestion().size(); i++) {
// See https://github.com/mapbox/mapbox-navigation-android/issues/353
if (leg.annotation().congestion().size() + 1 <= lineString.getCoordinates().size()) {
double[] startCoord = lineString.getCoordinates().get(i).getCoordinates();
double[] endCoord = lineString.getCoordinates().get(i + 1).getCoordinates();
LineString congestionLineString = LineString.fromCoordinates(new double[][] { startCoord, endCoord });
Feature feature = Feature.fromGeometry(congestionLineString);
feature.addStringProperty(CONGESTION_KEY, leg.annotation().congestion().get(i));
feature.addStringProperty(SOURCE_KEY, String.format(Locale.US, ID_FORMAT, GENERIC_ROUTE_SOURCE_ID, index));
feature.addNumberProperty(INDEX_KEY, index);
features.add(feature);
}
}
} else {
Feature feature = Feature.fromGeometry(lineString);
features.add(feature);
}
}
}
use of com.mapbox.services.commons.geojson.Feature in project mapbox-navigation-android by mapbox.
the class MapUtils method updateMapSourceFromFeatureCollection.
/**
* Takes a {@link FeatureCollection} and creates a map GeoJson source using the sourceId also
* provided.
*
* @param mapboxMap that the current mapView is using
* @param collection the feature collection to be added to the map style
* @param sourceId the source's id for identifying it when adding layers
* @since 0.8.0
*/
public static void updateMapSourceFromFeatureCollection(@NonNull MapboxMap mapboxMap, @Nullable FeatureCollection collection, @NonNull String sourceId) {
if (collection == null) {
collection = FeatureCollection.fromFeatures(new Feature[] {});
}
GeoJsonSource source = mapboxMap.getSourceAs(sourceId);
if (source == null) {
GeoJsonOptions routeGeoJsonOptions = new GeoJsonOptions().withMaxZoom(16);
GeoJsonSource routeSource = new GeoJsonSource(sourceId, collection, routeGeoJsonOptions);
mapboxMap.addSource(routeSource);
} else {
source.setGeoJson(collection);
}
}
use of com.mapbox.services.commons.geojson.Feature in project androidApp by InspectorIncognito.
the class BusStopPlugin method moveCenterInAndOpen.
public void moveCenterInAndOpen(String id) {
if (selectedBusStop != null) {
if (selectedBusStop.getStringProperty(Marker.PROPERTY_ID).equals(id)) {
MapboxUtil.animateCameraToSelection(selectedBusStop, animatorSet, mapboxMap);
return;
} else {
deselectSelectedBusStop();
}
}
Feature busStopFeature = getFeature(id, busStopFeatures, BusStopMarker.PROPERTY_ID);
BusStopClickHandler handler = new BusStopClickHandler(getContext().getResources(), periodicRequestHandler, BusStopPlugin.this);
if (busStopFeature == null) {
BusStopHelper helper = new BusStopHelper(getContext());
ArrayList<BusStop> busStops = new ArrayList<>();
busStops.add(helper.getBusStopById(id));
updateBusStopSource(busStops);
busStopFeature = busStopFeatures.getFeatures().get(0);
}
busStopFeatureClick(busStopFeature, handler);
}
Aggregations