use of com.mapbox.mapboxsdk.geometry.LatLng in project androidApp by InspectorIncognito.
the class MapboxUtil method getRotatePoint.
public static LatLng getRotatePoint(Feature pointToRotate, Feature pivotPoint, double bearing) {
LatLng p1 = convertToLatLng(pointToRotate);
LatLng p2 = convertToLatLng(pivotPoint);
int distance = distanceTo(p1, p2);
return destinationPoint(p2, distance, (float) bearing);
}
use of com.mapbox.mapboxsdk.geometry.LatLng in project androidApp by InspectorIncognito.
the class RouteHelper method cursorToRouteList.
/**
* Creates a List<Pair> based on the Cursor information
*
* @param cursor
* @return List of RoutePoint
*/
private ArrayList<LatLng> cursorToRouteList(Cursor cursor) {
ArrayList<LatLng> route = new ArrayList<>();
while (cursor.moveToNext()) {
double lat = cursor.getDouble(2);
double lon = cursor.getDouble(3);
route.add(new LatLng(lat, lon));
}
return route;
}
use of com.mapbox.mapboxsdk.geometry.LatLng in project androidApp by InspectorIncognito.
the class RouteHelper method getRoute.
/**
* Return a list of pair<latitude, longitude> that describe the route of a service
* with a direction defined.
*
* @param serviceName Name of bus service, ex: 506, 506e, D03, D03N
* @param direction the route direction used by service
* @return List of pair<latitude,longitude>
*/
public ArrayList<LatLng> getRoute(String serviceName, String direction) {
String query = "SELECT * FROM " + DataBaseContract.Route.TABLE_NAME + " WHERE " + DataBaseContract.Route.SERVICE + " = ?" + " ORDER BY " + DataBaseContract.Route.SEQUENCE + " ASC";
String[] params = new String[] { serviceName + direction };
Cursor cursor = this.getReadableDatabase().rawQuery(query, params);
ArrayList<LatLng> route = this.cursorToRouteList(cursor);
cursor.close();
this.close();
return route;
}
use of com.mapbox.mapboxsdk.geometry.LatLng in project androidApp by InspectorIncognito.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate");
busButton = new BusToggleButton((ImageView) findViewById(R.id.floating_button_bus), null, false);
userMapLevel = findViewById(R.id.user_map_level);
userMapLevel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
openActivity(AccountActivity.class);
}
});
findViewById(R.id.floating_button_bus).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
busButtonClick();
}
});
// Sliding Panel Initialization
initializeSlidingPanel();
tittleView = getLayoutInflater().inflate(R.layout.activity_main_title_bar, null);
tittleText = tittleView.findViewById(R.id.activity_main_title_text);
tittleImage = tittleView.findViewById(R.id.activity_main_title_image);
// Connection Message
MessageLayout = findViewById(R.id.textOfflineBar);
ConnectionChange = ConnectionChangeReceiver.getBroadcastReceiverInstance();
// Create supportMapFragment
if (savedInstanceState == null) {
// Create fragment
final FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
Location location = PositionProvider.getInstance().getLastKnownLocation();
// Build mapboxMap
MapboxMapOptions options = new MapboxMapOptions();
options.styleUrl(Style.MAPBOX_STREETS);
options.camera(new CameraPosition.Builder().target(new LatLng(location.getLatitude(), location.getLongitude())).zoom(16).build());
// Create map fragment
mapFragment = VectorMapFragment.newInstance(options);
// Add map fragment to parent container
transaction.add(R.id.container, mapFragment, "com.mapbox.map");
transaction.commit();
} else {
mapFragment = (VectorMapFragment) getSupportFragmentManager().findFragmentByTag("com.mapbox.map");
}
Bundle extras = getIntent().getExtras();
if (extras != null) {
if (extras.containsKey(BUS_SERVICE_KEY) && extras.containsKey(BUS_TOKEN_KEY)) {
showEvaluationDialog(extras.getString(BUS_SERVICE_KEY), extras.getString(BUS_TOKEN_KEY));
}
}
onFoot();
}
use of com.mapbox.mapboxsdk.geometry.LatLng 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;
}
};
}
Aggregations