use of cl.smartcities.isci.transportinspector.map.engine.MultiLocationEngine in project androidApp by InspectorIncognito.
the class RouterVectorMapFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap aMapboxMap) {
mapboxMap = aMapboxMap;
mapboxMap.getUiSettings().setCompassMargins(0, 14 * getResources().getDisplayMetrics().heightPixels / 100, 4 * getResources().getDisplayMetrics().widthPixels / 100, 0);
routerPlugin = new RouterPlugin(mapboxMap, new RedirectionListener(getActivity()));
if (selectedRoute != null) {
innerSetRoute(selectedRoute);
selectedRoute = null;
}
locationEngine = new MultiLocationEngine();
locationPlugin = new UserPlugin(mapView, mapboxMap, locationEngine);
mapboxMap.addOnScrollListener(new MapboxMap.OnScrollListener() {
@Override
public void onScroll() {
centerButton.deselectButton();
locationPlugin.setTrackingEnabled(false);
}
});
centerButton = new LocationToggleButton((ImageButton) getActivity().findViewById(R.id.floating_button_center), new LocationToggleButton.OnToggleButtonCheck() {
@Override
public void onButtonSelected() {
if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(locationEngine.getLastLocation().getLatitude(), locationEngine.getLastLocation().getLongitude()), 16));
locationPlugin.setTrackingEnabled(true);
}
@Override
public void onButtonUnselected() {
locationPlugin.setTrackingEnabled(false);
}
}, false);
enableLocationPlugin();
mapView.setVisibility(View.VISIBLE);
}
});
}
use of cl.smartcities.isci.transportinspector.map.engine.MultiLocationEngine in project androidApp by InspectorIncognito.
the class VectorSearchMapFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap resMapboxMap) {
mapboxMap = resMapboxMap;
// mapboxMap.getUiSettings().setCompassImage(ContextCompat.getDrawable(getContext(), R.drawable.direction_arrow));
mapboxMap.addOnMapClickListener(new MapboxMap.OnMapClickListener() {
@Override
public void onMapClick(@NonNull LatLng point) {
}
});
mapboxMap.getUiSettings().setCompassMargins(0, 14 * getResources().getDisplayMetrics().heightPixels / 100, 4 * getResources().getDisplayMetrics().widthPixels / 100, 0);
searchPlugin = new SearchPlugin(redirectionListener, service, routeHelper, mapboxMap);
locationEngine = new MultiLocationEngine();
locationPlugin = new UserPlugin(mapView, mapboxMap, locationEngine);
mapboxMap.addOnScrollListener(new MapboxMap.OnScrollListener() {
@Override
public void onScroll() {
centerButton.deselectButton();
locationPlugin.setTrackingEnabled(false);
}
});
centerButton = new LocationToggleButton((ImageButton) getActivity().findViewById(R.id.floating_button_center), new LocationToggleButton.OnToggleButtonCheck() {
@Override
public void onButtonSelected() {
if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(locationEngine.getLastLocation().getLatitude(), locationEngine.getLastLocation().getLongitude()), 16));
locationPlugin.setTrackingEnabled(true);
}
@Override
public void onButtonUnselected() {
locationPlugin.setTrackingEnabled(false);
}
}, false);
enableLocationPlugin();
Location lastLocation = locationEngine.getLastLocation();
zoomBound(new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude()));
}
});
}
use of cl.smartcities.isci.transportinspector.map.engine.MultiLocationEngine in project androidApp by InspectorIncognito.
the class VectorMapFragment method onViewCreated.
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
Log.d("VectorMapFragment", "onViewCreated");
super.onViewCreated(view, savedInstanceState);
getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap resMapboxMap) {
mapboxMap = resMapboxMap;
clickListeners = new ArrayList<>();
// mapboxMap.getUiSettings().setCompassImage(ContextCompat.getDrawable(getContext(), R.drawable.direction_arrow));
mapboxMap.addOnMapClickListener(new MapboxMap.OnMapClickListener() {
@Override
public void onMapClick(@NonNull LatLng point) {
for (MultiLayerOnMapClickListener listener : clickListeners) {
if (listener.onMapClick(point)) {
return;
}
}
}
});
locationEngine = new MultiLocationEngine();
mapboxMap.getUiSettings().setCompassMargins(0, 27 * getResources().getDisplayMetrics().heightPixels / 100, 4 * getResources().getDisplayMetrics().widthPixels / 100, 0);
onBusEngine = new OnBusEngine(mapboxMap);
busStopPlugin = new BusStopPlugin(mapboxMap, getContext(), VectorMapFragment.this, onBusEngine);
busUserPlugin = new BusUserPlugin(mapView, mapboxMap, locationEngine, VectorMapFragment.this, onBusEngine);
clickListeners.add(busUserPlugin.getOnMapClickListener());
clickListeners.add(busStopPlugin.getOnMapClickListener());
outOfBusStopStackFrame = new MainActivity.OnBackButtonStack() {
@Override
public void onPressBackButton() {
busStopPlugin.clearSelectedFeature();
}
};
mapboxMap.addOnScrollListener(new MapboxMap.OnScrollListener() {
@Override
public void onScroll() {
centerButton.deselectButton();
busUserPlugin.setTrackingEnabled(false);
}
});
centerButton = new LocationToggleButton((ImageButton) getActivity().findViewById(R.id.floating_button_center), new LocationToggleButton.OnToggleButtonCheck() {
@Override
public void onButtonSelected() {
Log.d("VectorMapFragment", "onButtonSelected");
if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(locationEngine.getLastLocation().getLatitude(), locationEngine.getLastLocation().getLongitude()), 16));
busUserPlugin.setTrackingEnabled(true);
}
@Override
public void onButtonUnselected() {
busUserPlugin.setTrackingEnabled(false);
}
}, true);
enableLocationPlugin();
if (savedBus != null) {
changeToOnBus(savedBus);
savedBus = null;
}
}
});
}
Aggregations