use of cl.smartcities.isci.transportinspector.map.model.bus.BusClickHandler 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 cl.smartcities.isci.transportinspector.map.model.bus.BusClickHandler in project androidApp by InspectorIncognito.
the class BusStopPlugin 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(BusStopMarker.PROPERTY_TYPE) && feature.getStringProperty(BusStopMarker.PROPERTY_TYPE).equals(BusStopMarker.PROPERTY_TYPE_BUS_STOP)) {
BusStopClickHandler handler = new BusStopClickHandler(getContext().getResources(), periodicRequestHandler, BusStopPlugin.this);
// BUS STOP FEATURE CLICK
final List<Feature> busStopsInfoWindows = mapboxMap.queryRenderedFeatures(screenPoint, BUS_STOP_INFO_WINDOW_LAYER_ID_MAX, BUS_STOP_INFO_WINDOW_LAYER_ID_MIN);
if (!busStopsInfoWindows.isEmpty()) {
// INFO WINDOW CLICK
Feature busStopInfoWindowFeature = getFeatureByStringProperty(busStopsInfoWindows.get(0), busStopFeatures, BusStopMarker.PROPERTY_ID);
PointF symbolScreenPoint = mapboxMap.getProjection().toScreenLocation(MapboxUtil.convertToLatLng(busStopInfoWindowFeature));
if (handler.handleInfoWindowClick(busStopInfoWindowFeature, screenPoint, symbolScreenPoint, viewMap)) {
if (selectedBus != null) {
deselectSelectedBusFeature();
centerCameraInSelection(busStopInfoWindowFeature);
}
refreshBusStopSource();
}
return true;
} else {
// MARKER CLICK
Log.d(BusStopPlugin.class.getSimpleName(), "MARKER CLICK");
busStopFeatureClick(feature, handler);
return true;
}
} else if (feature.hasProperty(BusMarker.PROPERTY_TYPE) && feature.getStringProperty(BusMarker.PROPERTY_TYPE).equals(BusMarker.PROPERTY_TYPE_BUS)) {
// BUS FEATURE CLICK
final List<Feature> infoWindowFeature = mapboxMap.queryRenderedFeatures(screenPoint, BUS_INFO_WINDOW_LAYER_ID_MAX);
if (!infoWindowFeature.isEmpty()) {
BusClickHandler handler = new BusClickHandler(getContext().getResources(), periodicRequestHandler, listener);
Feature selectedFeature = getFeatureByStringProperty(infoWindowFeature.get(0), busesFeatures, Marker.PROPERTY_ID);
PointF symbolScreenPoint = mapboxMap.getProjection().toScreenLocation(MapboxUtil.convertToLatLng(feature));
assert (selectedFeature) != null;
if (handler.handleInfoWindowClick(((BusMarker) selectedFeature).getBus(), screenPoint, symbolScreenPoint, viewMap, false)) {
return true;
}
}
busFeatureClick(feature);
return true;
}
}
// we didn't find a click event on any layer
if (busStopServiceCall != null && !busStopServiceCall.isCanceled()) {
Log.d(BusStopPlugin.class.getSimpleName(), "busStopServiceCall.cancel()");
busStopServiceCall.cancel();
} else if (selectedBusStop != null) {
deselectSelectedBusStop();
}
return false;
}
};
}
Aggregations