use of com.mapbox.mapboxsdk.maps.OnMapReadyCallback in project apps-android-commons by commons-app.
the class NearbyMapFragment method setupMapView.
private void setupMapView(Bundle savedInstanceState) {
MapboxMapOptions options = new MapboxMapOptions().styleUrl(Style.OUTDOORS).camera(new CameraPosition.Builder().target(new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude())).zoom(11).build());
// create map
mapView = new MapView(getActivity(), options);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
mapboxMap.addMarkers(baseMarkerOptions);
mapboxMap.setOnMarkerClickListener(new MapboxMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(@NonNull Marker marker) {
if (marker instanceof NearbyMarker) {
NearbyMarker nearbyMarker = (NearbyMarker) marker;
Place place = nearbyMarker.getNearbyBaseMarker().getPlace();
NearbyInfoDialog.showYourself(getActivity(), place);
}
return false;
}
});
addCurrentLocationMarker(mapboxMap);
}
});
if (PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("theme", true)) {
mapView.setStyleUrl(getResources().getString(R.string.map_theme_dark));
} else {
mapView.setStyleUrl(getResources().getString(R.string.map_theme_light));
}
}
use of com.mapbox.mapboxsdk.maps.OnMapReadyCallback in project osm-contributor by jawg.
the class OfflineRegionsActivity method initMapView.
private void initMapView(Bundle savedInstanceState) {
mapView.onCreate(savedInstanceState);
mapView.setStyleUrl(BuildConfig.MAP_STYLE);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
OfflineRegionsActivity.this.mapboxMap = mapboxMap;
mapboxMap.getUiSettings().setCompassEnabled(false);
mapboxMap.getUiSettings().setRotateGesturesEnabled(false);
mapboxMap.getUiSettings().setTiltGesturesEnabled(false);
enableMapGestures(false);
}
});
}
use of com.mapbox.mapboxsdk.maps.OnMapReadyCallback 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 com.mapbox.mapboxsdk.maps.OnMapReadyCallback 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 com.mapbox.mapboxsdk.maps.OnMapReadyCallback in project mapbox-plugins-android by mapbox.
the class OfflineRegionDetailActivity method setupUI.
private void setupUI(final OfflineTilePyramidRegionDefinition definition) {
// update map
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
// correct style
mapboxMap.setStyle(definition.getStyleURL());
// position map on top of offline region
CameraPosition cameraPosition = OfflineUtils.getCameraPosition(definition);
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
// restrict camera movement
mapboxMap.setMinZoomPreference(definition.getMinZoom());
mapboxMap.setMaxZoomPreference(definition.getMaxZoom());
mapboxMap.setLatLngBoundsForCameraTarget(definition.getBounds());
}
});
// update textview data
nameView.setText(OfflineUtils.convertRegionName(offlineRegion.getMetadata()));
styleView.setText(definition.getStyleURL());
latLngBoundsView.setText(definition.getBounds().toString());
minZoomView.setText(String.valueOf(definition.getMinZoom()));
maxZoomView.setText(String.valueOf(definition.getMaxZoom()));
offlineRegion.getStatus(offlineRegionStatusCallback);
}
Aggregations