use of com.mapbox.mapboxsdk.style.sources.GeoJsonSource in project androidApp by InspectorIncognito.
the class PolylineEngine method setupBusRouteSource.
private void setupBusRouteSource(MapboxMap mapboxMap) {
busRouteStartSource = new GeoJsonSource(LocationLayerConstants.SOURCE_USER_BUS_ROUTE_START, busRouteStartFeature);
mapboxMap.addSource(busRouteStartSource);
busRouteEndSource = new GeoJsonSource(LocationLayerConstants.SOURCE_USER_BUS_ROUTE_END, busRouteEndFeature);
mapboxMap.addSource(busRouteEndSource);
}
use of com.mapbox.mapboxsdk.style.sources.GeoJsonSource in project androidApp by InspectorIncognito.
the class BusStopPlugin method setupBusStopSource.
private void setupBusStopSource() {
busStopSource = new GeoJsonSource(SOURCE_BUS_STOPS, busStopFeatures);
mapboxMap.addSource(busStopSource);
}
use of com.mapbox.mapboxsdk.style.sources.GeoJsonSource in project androidApp by InspectorIncognito.
the class BusUserPlugin method getOnMapClickListener.
public MultiLayerOnMapClickListener getOnMapClickListener() {
return new MultiLayerOnMapClickListener() {
@Override
public boolean onMapClick(@NonNull LatLng point) {
PointF screenPoint = mapboxMap.getProjection().toScreenLocation(point);
final List<Feature> allFeatures = mapboxMap.queryRenderedFeatures(screenPoint);
Collections.reverse(allFeatures);
for (Feature feature : allFeatures) {
if (feature.hasProperty(LocationLayerConstants.PROPERTY_ON_BUS) && feature.getBooleanProperty(LocationLayerConstants.PROPERTY_ON_BUS).equals(true)) {
// BUS FEATURE CLICK
final List<Feature> infoWindowFeature = mapboxMap.queryRenderedFeatures(screenPoint, LocationLayerConstants.LOCATION_LAYER_INFO_WINDOW);
if (!infoWindowFeature.isEmpty()) {
PeriodicRequestHandler periodicRequestHandler = new PeriodicRequestHandler(TranSappApplication.getAppContext(), null, null);
BusClickHandler handler = new BusClickHandler(TranSappApplication.getAppContext().getResources(), periodicRequestHandler, listener);
PointF symbolScreenPoint = mapboxMap.getProjection().toScreenLocation(MapboxUtil.convertToLatLng(feature));
if (handler.handleInfoWindowClick(currentUserBus, screenPoint, symbolScreenPoint, viewMap, true)) {
return true;
}
minimizeFeature();
return true;
}
userLocationFeature.addBooleanProperty(LocationLayerConstants.PROPERTY_MAXIMIZED, true);
GeoJsonSource locationGeoJsonSource = mapboxMap.getSourceAs(LocationLayerConstants.LOCATION_SOURCE);
if (locationGeoJsonSource == null) {
return true;
}
locationGeoJsonSource.setGeoJson(userLocationFeature);
return true;
}
}
// we didn't find a click event on any layer
minimizeFeature();
return false;
}
};
}
use of com.mapbox.mapboxsdk.style.sources.GeoJsonSource in project androidApp by InspectorIncognito.
the class BusUserPlugin method setOnBus.
private void setOnBus() {
final GeoJsonSource locationGeoJsonSource = mapboxMap.getSourceAs(LocationLayerConstants.LOCATION_SOURCE);
if (locationGeoJsonSource == null) {
return;
}
this.directionDetectionEngine = new DirectionEngine(10, currentUserBus.getService());
ArrayList<IconBuilder> buildingList = new ArrayList<>();
buildingList.add(new UserBusIconsBuilder(currentUserBus).toBuilder());
GenerateViewIconTask task = new GenerateViewIconTask(new GenerateViewIconTask.ImageLoaderListener() {
@Override
public void onImageGenResult(HashMap<String, View> viewMap, HashMap<String, Bitmap> bitmapHashMap) {
if (mapboxMap != null) {
mapboxMap.addImages(bitmapHashMap);
} else {
return;
}
BearingEngine.Orientation orientation;
if (currentUserBus.isFlipped()) {
userLocationFeature.addStringProperty(LocationLayerConstants.PROPERTY_ORIENTATION, "LEFT");
orientation = BearingEngine.Orientation.Left;
} else {
userLocationFeature.addStringProperty(LocationLayerConstants.PROPERTY_ORIENTATION, "RIGHT");
orientation = BearingEngine.Orientation.Right;
}
userLocationFeature.addBooleanProperty(LocationLayerConstants.PROPERTY_ON_BUS, true);
bearingEngine = new BearingEngine(mapboxMap, previousPoint, orientation);
if (currentUserBus.getDirection() != null && !currentUserBus.getDirection().isEmpty()) {
onBusEngine.setOnBus(currentUserBus);
}
locationGeoJsonSource.setGeoJson(userLocationFeature);
mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(MapboxUtil.convertToLatLng(userLocationFeature)));
}
}, viewMap, buildingList);
task.execute();
}
use of com.mapbox.mapboxsdk.style.sources.GeoJsonSource in project androidApp by InspectorIncognito.
the class BusUserPlugin method setBusAvatarId.
public void setBusAvatarId(int busAvatarId) {
if (currentUserBus == null) {
return;
}
currentUserBus.setAvatarId(busAvatarId);
ArrayList<IconBuilder> buildingList = new ArrayList<>();
buildingList.add(new UserBusIconsBuilder(currentUserBus).toBuilder());
GenerateViewIconTask task = new GenerateViewIconTask(new GenerateViewIconTask.ImageLoaderListener() {
@Override
public void onImageGenResult(HashMap<String, View> viewMap, HashMap<String, Bitmap> bitmapHashMap) {
if (mapboxMap != null) {
mapboxMap.addImages(bitmapHashMap);
} else {
return;
}
GeoJsonSource locationGeoJsonSource = mapboxMap.getSourceAs(LocationLayerConstants.LOCATION_SOURCE);
if (locationGeoJsonSource != null) {
locationGeoJsonSource.setGeoJson(userLocationFeature);
}
}
}, viewMap, buildingList);
task.execute();
}
Aggregations